Skip to content

Commit 427c244

Browse files
committed
Fix GH-14124: Segmentation fault on unknown address 0x0001ffff8041 with XML extension under certain memory limit (#14126)
The ltags were not initialized, so when an OOM happens before the new value is written, uninitialized data is used.
1 parent 3237b8f commit 427c244

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ PHP NEWS
1313
. Fix crash when calling childNodes next() when iterator is exhausted.
1414
(nielsdos)
1515

16+
- XML:
17+
. Fixed bug GH-14124 (Segmentation fault with XML extension under certain
18+
memory limit). (nielsdos)
19+
1620
09 May 2024, PHP 8.2.19
1721

1822
- Core:

ext/xml/xml.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,7 @@ PHP_FUNCTION(xml_parse_into_struct)
12921292
parser->level = 0;
12931293
xml_parser_free_ltags(parser);
12941294
parser->ltags = safe_emalloc(XML_MAXLEVEL, sizeof(char *), 0);
1295+
memset(parser->ltags, 0, XML_MAXLEVEL * sizeof(char *));
12951296

12961297
XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler);
12971298
XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler);

0 commit comments

Comments
 (0)