Skip to content

Commit a161e90

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

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

ext/standard/string.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3988,19 +3988,23 @@ static zend_always_inline char *php_stripslashes_impl(const char *str, char *out
39883988
quad_word q;
39893989
vst1q_u8(q.mem, vceqq_u8(x, vdupq_n_u8('\\')));
39903990
if (q.dw[0] | q.dw[1]) {
3991-
int i = 0;
3992-
for (; i < 16; i++) {
3991+
unsigned int i = 0;
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)