Skip to content

Commit bb60122

Browse files
committed
fix invalid read when trimming empty string
1 parent 065862a commit bb60122

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
@@ -107,8 +107,10 @@
107107
if (len < 1) { \
108108
RETURN_VALIDATION_FAILED \
109109
} \
110-
while (p[len-1] == ' ' || p[len-1] == '\t' || p[len-1] == '\r' || p[len-1] == '\v' || p[len-1] == '\n') { \
111-
len--; \
110+
if (len > 0) { \
111+
while (p[len-1] == ' ' || p[len-1] == '\t' || p[len-1] == '\r' || p[len-1] == '\v' || p[len-1] == '\n') { \
112+
len--; \
113+
} \
112114
} \
113115
}
114116

0 commit comments

Comments
 (0)