From: simon Date: Wed, 17 Jun 2009 17:27:53 +0000 (+0000) Subject: After incrementing an unsigned char value, don't cast it back to X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/commitdiff_plain/2f23825bf6ba960e29d710dd9b83ec6973166ea7 After incrementing an unsigned char value, don't cast it back to unsigned char if you want to preserve its ordering! Fixes a bug whereby an 0xFF character in a filename could trigger an assertion failure (since du.c would sort the directory contents correctly but trie.c would then expect it to be sorted wrong). git-svn-id: svn://svn.tartarus.org/sgt/agedu@8595 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/trie.c b/trie.c index ddadddb..48302db 100644 --- a/trie.c +++ b/trie.c @@ -15,9 +15,9 @@ */ static int trieccmp(unsigned char a, unsigned char b) { - a = (a == '\0' ? '\0' : a == pathsep ? '\1' : a+1); - b = (b == '\0' ? '\0' : b == pathsep ? '\1' : b+1); - return (int)a - (int)b; + int ia = (a == '\0' ? '\0' : a == pathsep ? '\1' : a+1); + int ib = (b == '\0' ? '\0' : b == pathsep ? '\1' : b+1); + return ia - ib; } static int triencmp(const char *a, size_t alen,