Skip to content

Commit b9bc316

Browse files
committed
Fix GH-10187: Segfault in stripslashes() with arm64
1 parent adc2382 commit b9bc316

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ext/standard/string.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3989,18 +3989,22 @@ static zend_always_inline char *php_stripslashes_impl(const char *str, char *out
39893989
vst1q_u8(q.mem, vceqq_u8(x, vdupq_n_u8('\\')));
39903990
if (q.dw[0] | q.dw[1]) {
39913991
int i = 0;
3992-
for (; i < 16; i++) {
3992+
while (i < 16) {
39933993
if (q.mem[i] == 0) {
39943994
*out++ = str[i];
3995+
i++;
39953996
continue;
39963997
}
39973998

39983999
i++; /* skip the slash */
3999-
char s = str[i];
4000-
if (s == '0')
4001-
*out++ = '\0';
4002-
else
4003-
*out++ = s; /* preserve the next character */
4000+
if (i < len) {
4001+
char s = str[i];
4002+
if (s == '0')
4003+
*out++ = '\0';
4004+
else
4005+
*out++ = s; /* preserve the next character */
4006+
i++;
4007+
}
40044008
}
40054009
str += i;
40064010
len -= i;

0 commit comments

Comments
 (0)