summaryrefslogtreecommitdiffstats
path: root/ascii.c
diff options
context:
space:
mode:
authorMichael Elkins <me@sigpipe.org>2012-12-01 14:31:42 -0800
committerMichael Elkins <me@sigpipe.org>2012-12-01 14:31:42 -0800
commit521eadd0c7526cbe88c60e0bd94a5f93b2c348ef (patch)
tree4e8d7b9f8404968f93feeca1c0cd75879ae692c4 /ascii.c
parent3eeae6ed6618c2176a0a5df09bacfb8d42e6daca (diff)
make ascii_strcasecmp properly handle unequal length strings with the same prefix
closes #3601
Diffstat (limited to 'ascii.c')
-rw-r--r--ascii.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ascii.c b/ascii.c
index 1076f8f2..45f7e5d0 100644
--- a/ascii.c
+++ b/ascii.c
@@ -71,10 +71,15 @@ int ascii_strcasecmp (const char *a, const char *b)
if (b == NULL && a)
return 1;
- for (; *a || *b; a++, b++)
+ for (;; a++, b++)
{
if ((i = ascii_tolower (*a) - ascii_tolower (*b)))
return i;
+ /* test for NUL here rather that in the for loop in order to detect unqual
+ * length strings (see http://dev.mutt.org/trac/ticket/3601)
+ */
+ if (!*a)
+ break;
}
return 0;