]> granicus.if.org Git - php/commitdiff
fix invalid read when trimming empty string
authorAntony Dovgal <tony2001@php.net>
Sun, 11 Nov 2012 18:37:04 +0000 (22:37 +0400)
committerAntony Dovgal <tony2001@php.net>
Sun, 11 Nov 2012 18:38:14 +0000 (22:38 +0400)
ext/filter/filter_private.h

index 2ec2f62fae733852f7d546d49bcaf2ccfcf55fa1..0f76d7a032a7159d637ab58e187cf0df07e2de6d 100644 (file)
        if (len < 1 && return_if_empty) { \
                RETURN_VALIDATION_FAILED \
        } \
-       while (p[len-1] == ' ' || p[len-1] == '\t' || p[len-1] == '\r' || p[len-1] == '\v' || p[len-1] == '\n') { \
-               len--; \
+       if (len > 0) { \
+               while (p[len-1] == ' ' || p[len-1] == '\t' || p[len-1] == '\r' || p[len-1] == '\v' || p[len-1] == '\n') { \
+                       len--; \
+               } \
        } \
 }