diff options
author | Michael Elkins <me@sigpipe.org> | 2012-12-01 14:31:42 -0800 |
---|---|---|
committer | Michael Elkins <me@sigpipe.org> | 2012-12-01 14:31:42 -0800 |
commit | 521eadd0c7526cbe88c60e0bd94a5f93b2c348ef (patch) | |
tree | 4e8d7b9f8404968f93feeca1c0cd75879ae692c4 /ascii.c | |
parent | 3eeae6ed6618c2176a0a5df09bacfb8d42e6daca (diff) |
make ascii_strcasecmp properly handle unequal length strings with the same prefix
closes #3601
Diffstat (limited to 'ascii.c')
-rw-r--r-- | ascii.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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; |