-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Null pointer dereference in DOMElement -> getAttributeNames() #16149
Labels
Comments
Possible fix (would at least avoid the segfault): ext/dom/element.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/ext/dom/element.c b/ext/dom/element.c
index 06af759365..da74296ffa 100644
--- a/ext/dom/element.c
+++ b/ext/dom/element.c
@@ -361,6 +361,7 @@ PHP_METHOD(DOMElement, getAttributeNames)
if (!php_dom_follow_spec_intern(intern)) {
for (xmlNsPtr nsptr = nodep->nsDef; nsptr; nsptr = nsptr->next) {
const char *prefix = (const char *) nsptr->prefix;
+ if (prefix == NULL) continue;
ZVAL_NEW_STR(&tmp, dom_node_concatenated_name_helper(strlen(prefix), prefix, strlen("xmlns"), (const char *) "xmlns"));
zend_hash_next_index_insert(ht, &tmp);
} |
@cmb69 Almost, but since it has a namespace "a", it should contain an "xmlns" entry. I'll make a PR. |
nielsdos
added a commit
to nielsdos/php-src
that referenced
this issue
Oct 1, 2024
…Names() A namespace without a prefix is by definition always the "xmlns" namespace.
nielsdos
added a commit
that referenced
this issue
Oct 1, 2024
* PHP-8.3: Fix GH-16149: Null pointer dereference in DOMElement->getAttributeNames()
nielsdos
added a commit
that referenced
this issue
Oct 1, 2024
* PHP-8.4: Fix GH-16149: Null pointer dereference in DOMElement->getAttributeNames()
jorgsowa
pushed a commit
to jorgsowa/php-src
that referenced
this issue
Oct 1, 2024
…Names() A namespace without a prefix is by definition always the "xmlns" namespace. Closes phpGH-16155.
jorgsowa
pushed a commit
to jorgsowa/php-src
that referenced
this issue
Oct 1, 2024
…Names() A namespace without a prefix is by definition always the "xmlns" namespace. Closes phpGH-16155.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The following code:
Resulted in this output:
But I expected this output instead:
PHP Version
PHP 8.4.0-dev
Operating System
No response
The text was updated successfully, but these errors were encountered: