Skip to content

Commit 1a78bda

Browse files
theodorejbcmb69
authored andcommitted
Fix #78454: Consecutive numeric separators cause OOM error
Resolves out of memory error when consecutive numeric separators follow a binary/hex literal.
1 parent ac40d0f commit 1a78bda

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ PHP NEWS
99
(cmb, Nikita)
1010
. Fixed bug #78441 (Parse error due to heredoc identifier followed by digit).
1111
(cmb)
12+
. Fixed bug #78454 (Consecutive numeric separators cause OOM error).
13+
(Theodore Brown)
1214

1315
- SPL:
1416
. Fixed bug #78436 (Missing addref in SplPriorityQueue EXTR_BOTH mode).

Zend/tests/bug78454_1.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--TEST--
2+
Invalid consecutive numeric separators after hex literal
3+
--FILE--
4+
<?php
5+
0x0__F;
6+
--EXPECTF--
7+
Parse error: syntax error, unexpected '__F' (T_STRING) in %s on line %d

Zend/tests/bug78454_2.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--TEST--
2+
Invalid consecutive numeric separators after binary literal
3+
--FILE--
4+
<?php
5+
0b0__1
6+
--EXPECTF--
7+
Parse error: syntax error, unexpected '__1' (T_STRING) in %s on line %d

Zend/zend_language_scanner.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
17751775
char *end, *bin = yytext + 2;
17761776

17771777
/* Skip any leading 0s */
1778-
while (*bin == '0' || *bin == '_') {
1778+
while (len > 0 && (*bin == '0' || *bin == '_')) {
17791779
++bin;
17801780
--len;
17811781
}
@@ -1892,7 +1892,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
18921892
char *end, *hex = yytext + 2;
18931893

18941894
/* Skip any leading 0s */
1895-
while (*hex == '0' || *hex == '_') {
1895+
while (len > 0 && (*hex == '0' || *hex == '_')) {
18961896
++hex;
18971897
--len;
18981898
}

0 commit comments

Comments
 (0)