[php-src] PHP-8.4: Fix GH-25306: Assertion status == LXB_STATUS_OK in dom_parse_selector when lexbor allocation fails
| From: | ndossche | Date: | Wed, 11 Nov 2026 10:14:35 +0000 |
| Subject: | [php-src] PHP-8.4: Fix GH-25306: Assertion status == LXB_STATUS_OK in dom_parse_selector when lexbor allocation fails | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143573@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-11-11T11:13:12+01:00
Commit: https://github.com/php/php-src/commit/e4f045070eace18e43618d4f2f0116d72d02af69
Raw diff: https://github.com/php/php-src/commit/e4f045070eace18e43618d4f2f0116d72d02af69.diff
Fix GH-25306: Assertion status == LXB_STATUS_OK in dom_parse_selector when lexbor allocation fails
Closes GH-25348.
Changed paths:
M NEWS
M ext/dom/parentnode/css_selectors.c
Diff:
diff --git a/NEWS b/NEWS
index 9397cd352ab6..18ec48a2acfe 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,8 @@ PHP NEWS
- DOM:
. Fixed bug GH-25268 (NULL php_libxml_ref_obj dereference in
dom_objects_store_clone_obj when cloning Dom\Notation). (David Carlier)
+ . Fixed bug GH-25306 (Assertion status == LXB_STATUS_OK in dom_parse_selector
+ when lexbor allocation fails). (ndossche)
- GD:
. Fixed use-after-free when drawing with a brush or tile image that was
diff --git a/ext/dom/parentnode/css_selectors.c b/ext/dom/parentnode/css_selectors.c
index 43012c4ebb99..8dd483ff0b62 100644
--- a/ext/dom/parentnode/css_selectors.c
+++ b/ext/dom/parentnode/css_selectors.c
@@ -83,11 +83,15 @@ static lxb_css_selector_list_t *dom_parse_selector(
memset(parser, 0, sizeof(lxb_css_parser_t));
status = lxb_css_parser_init(parser, NULL);
- ZEND_ASSERT(status == LXB_STATUS_OK);
+ if (UNEXPECTED(status != LXB_STATUS_OK)) {
+ return NULL;
+ }
memset(selectors, 0, sizeof(lxb_selectors_t));
status = lxb_selectors_init(selectors);
- ZEND_ASSERT(status == LXB_STATUS_OK);
+ if (UNEXPECTED(status != LXB_STATUS_OK)) {
+ return NULL;
+ }
lxb_selectors_opt_set(selectors, dom_quirks_opt(options, intern));
lxb_css_selector_list_t *list = lxb_css_selectors_parse(parser, (const lxb_char_t *)
ZSTR_VAL(selectors_str), ZSTR_LEN(selectors_str));