summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-01-04 01:22:14 +0100
committerNikita Popov <nikic@php.net>2014-01-04 01:22:14 +0100
commit7e8e21df0c9aa39278e994b05540b69920201b32 (patch)
tree94fceff5234da140798e49d204eac7d6d8ebeec4
parent46f60fae22b420320f3616e00928d70706cf4f4c (diff)
downloadphp-git-7e8e21df0c9aa39278e994b05540b69920201b32.tar.gz
Fix bug #66286: Incorrect object comparison with inheritance
std_compare_objects immidiately returned 0 if the property tables of both objects contain NULL at some index. Thus it would report objects as equal even though properties following after that differ.
-rw-r--r--NEWS3
-rw-r--r--Zend/tests/bug66286.phpt26
-rw-r--r--Zend/zend_object_handlers.c4
3 files changed, 29 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index b87803d5bf..cffe5ae7d0 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2013, PHP 5.4.25
+- Core:
+ . Fixed bug #66286 (Incorrect object comparison with inheritance). (Nikita)
+
?? ??? 2013, PHP 5.4.24
- Core:
diff --git a/Zend/tests/bug66286.phpt b/Zend/tests/bug66286.phpt
new file mode 100644
index 0000000000..457e282402
--- /dev/null
+++ b/Zend/tests/bug66286.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #66286: Incorrect object comparison with inheritance
+--FILE--
+<?php
+
+abstract class first {
+ protected $someArray = array();
+}
+
+class second extends first {
+ protected $someArray = array();
+ protected $someValue = null;
+
+ public function __construct($someValue) {
+ $this->someValue = $someValue;
+ }
+}
+
+$objFirst = new second('123');
+$objSecond = new second('321');
+
+var_dump ($objFirst == $objSecond);
+
+?>
+--EXPECT--
+bool(false)
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index b29cae4ea4..054c1bf553 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -1376,10 +1376,6 @@ static int zend_std_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
Z_OBJ_UNPROTECT_RECURSION(o1);
Z_OBJ_UNPROTECT_RECURSION(o2);
return 1;
- } else {
- Z_OBJ_UNPROTECT_RECURSION(o1);
- Z_OBJ_UNPROTECT_RECURSION(o2);
- return 0;
}
}
}