Skip to content

Commit 4029475

Browse files
committed
fix invalid read when trimming empty string
1 parent 80682bd commit 4029475

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/filter/filter_private.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@
109109
if (len < 1 && return_if_empty) { \
110110
RETURN_VALIDATION_FAILED \
111111
} \
112-
while (p[len-1] == ' ' || p[len-1] == '\t' || p[len-1] == '\r' || p[len-1] == '\v' || p[len-1] == '\n') { \
113-
len--; \
112+
if (len > 0) { \
113+
while (p[len-1] == ' ' || p[len-1] == '\t' || p[len-1] == '\r' || p[len-1] == '\v' || p[len-1] == '\n') { \
114+
len--; \
115+
} \
114116
} \
115117
}
116118

0 commit comments

Comments
 (0)