-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix #70359 and #78577 #11402
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
Fix #70359 and #78577 #11402
Conversation
ext/dom/php_dom.c
Outdated
attrp->ns = curns; | ||
|
||
php_dom_create_object(attrp, return_value, parent_intern); | ||
/* This object must exist, because we just created an object for it via DOM_RET_OBJ. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, should've said php_dom_create_object() in the comment instead of DOM_RET_OBJ... But CI is running now so I'll fix it in the merge..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this, going through the individual commits was definitely helpful.
ext/dom/php_dom.c
Outdated
@@ -1001,10 +1009,8 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml | |||
} | |||
/* }}} */ | |||
|
|||
static dom_object* dom_objects_set_class(zend_class_entry *class_type) /* {{{ */ | |||
static void dom_objects_set_class_ex(zend_class_entry *class_type, dom_object *intern) /* {{{ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit you probably want to remove the trailing /* {{{ */
comment
ext/dom/php_dom.c
Outdated
@@ -1028,6 +1038,26 @@ zend_object *dom_objects_new(zend_class_entry *class_type) | |||
} | |||
/* }}} */ | |||
|
|||
static zend_object *dom_objects_namespace_node_new(zend_class_entry *class_type) | |||
{ | |||
ZEND_ASSERT(class_type == dom_namespace_node_class_entry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be an issue if someone sets a custom class for namespace nodes?
Otherwise, just asserting it is an instance of the namespace node class should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it's not possible to register a custom class for DOMNameSpaceNode, likely because of an oversight.
I'll get rid of the assert anyway though, because this might be a problem when support is added in the future. The assert only had the purpose of sanity checking that I was using the right object handlers, so it's safe to remove.
It's the same issue that I fixed previously in phpGH-11402, but in a different place.
Fixes https://bugs.php.net/bug.php?id=70359 and https://bugs.php.net/bug.php?id=78577
Both these issues have the same underlying 2 problems. Even though these issue reports use debugging functionality, it also segfaults if you access some fields directly.
The 2 underlying problems are:
I've broken up the PR into individual commits to make it easier to follow for reviews. Will squash upon merge.