]> granicus.if.org Git - php/commitdiff
Fix undefined behaviour in strnatcmp
authorAndrea Faulds <ajf@ajf.me>
Sat, 13 Dec 2014 22:06:27 +0000 (22:06 +0000)
committerAndrea Faulds <ajf@ajf.me>
Sat, 13 Dec 2014 22:27:10 +0000 (22:27 +0000)
ext/standard/strnatcmp.c

index face191a6ede9c2c5cb83c25b72e8f4f389c1138..4b07740beaae4aff3f17e0ce3e0756ae1e96ed5f 100644 (file)
@@ -117,11 +117,11 @@ PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len
                ca = *ap; cb = *bp;
 
                /* skip over leading zeros */
-               while (leading && ca == '0' && (ap+1 < aend) && isdigit(*(ap+1))) {
+               while (leading && ca == '0' && (ap+1 < aend) && isdigit((int)(unsigned char)*(ap+1))) {
                        ca = *++ap;
                }
 
-               while (leading && cb == '0' && (bp+1 < bend) && isdigit(*(bp+1))) {
+               while (leading && cb == '0' && (bp+1 < bend) && isdigit((int)(unsigned char)*(bp+1))) {
                        cb = *++bp;
                }