Skip to content

Commit 82a34e7

Browse files
committed
Avoid overflow UB in is_numeric_string
We intentionally overflow the signed space here, so make this an unsigned variable and only cast to signed at the end.
1 parent 3d42986 commit 82a34e7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Zend/zend_operators.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,7 +3035,7 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t
30353035
int digits = 0, dp_or_e = 0;
30363036
double local_dval = 0.0;
30373037
zend_uchar type;
3038-
zend_long tmp_lval = 0;
3038+
zend_ulong tmp_lval = 0;
30393039
int neg = 0;
30403040

30413041
if (!length) {
@@ -3143,7 +3143,7 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t
31433143
if (neg) {
31443144
tmp_lval = -tmp_lval;
31453145
}
3146-
*lval = tmp_lval;
3146+
*lval = (zend_long) tmp_lval;
31473147
}
31483148

31493149
return IS_LONG;

0 commit comments

Comments
 (0)