summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-03-31 12:48:57 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-03-31 12:48:57 +0200
commit6bf483a94abcac24a3f1fc09feed2c6fbf5d648f (patch)
treee57beed991b238534dd2983b721b674d3c9a2000 /ext
parentfb5bfcb75b5a6abec2a07567769f6ae635d4399e (diff)
downloadphp-git-6bf483a94abcac24a3f1fc09feed2c6fbf5d648f.tar.gz
Clarify SimpleXML comparison logic
Diffstat (limited to 'ext')
-rw-r--r--ext/simplexml/simplexml.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 99ca0b2aa1..f44c268286 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -1291,16 +1291,24 @@ static int sxe_objects_compare(zval *object1, zval *object2) /* {{{ */
sxe1 = Z_SXEOBJ_P(object1);
sxe2 = Z_SXEOBJ_P(object2);
- if (sxe1->node == NULL) {
- if (sxe2->node) {
- return 1;
- } else if (sxe1->document->ptr == sxe2->document->ptr) {
+ if (sxe1->node != NULL && sxe2->node != NULL) {
+ /* Both nodes set: Only support equality comparison between nodes. */
+ if (sxe1->node == sxe2->node) {
return 0;
}
- return 1;
- } else {
- return !(sxe1->node == sxe2->node);
+ return ZEND_UNCOMPARABLE;
}
+
+ if (sxe1->node == NULL && sxe2->node == NULL) {
+ /* Both nodes not set: Only support equality comparison between documents. */
+ if (sxe1->document->ptr == sxe2->document->ptr) {
+ return 0;
+ }
+ return ZEND_UNCOMPARABLE;
+ }
+
+ /* Only one of the nodes set: Cannot compare. */
+ return ZEND_UNCOMPARABLE;
}
/* }}} */