Skip to content

Commit c8ec166

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #78454: Consecutive numeric separators cause OOM error
2 parents 743729d + 1a78bda commit c8ec166

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

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)