fix invalid read when trimming empty string

This commit is contained in:
Antony Dovgal 2012-11-11 22:37:04 +04:00
parent 964acdaa35
commit 5b82fb52fd

View File

@ -109,8 +109,10 @@
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--; \
} \
} \
}