]> granicus.if.org Git - php/commitdiff
Fix bug #66286: Incorrect object comparison with inheritance
authorNikita Popov <nikic@php.net>
Sat, 4 Jan 2014 00:22:14 +0000 (01:22 +0100)
committerNikita Popov <nikic@php.net>
Sat, 4 Jan 2014 00:22:14 +0000 (01:22 +0100)
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.

NEWS
Zend/tests/bug66286.phpt [new file with mode: 0644]
Zend/zend_object_handlers.c

diff --git a/NEWS b/NEWS
index b87803d5bf760441bf13c39205292b2a841a6d3e..cffe5ae7d01d360c79a1c84e96f95028bf66020f 100644 (file)
--- 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 (file)
index 0000000..457e282
--- /dev/null
@@ -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)
index b29cae4ea4074c1e345fcaa62864fb7bd1dfc50e..054c1bf553e2769958eaeadd74f33b900e9cd846 100644 (file)
@@ -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;
                                }
                        }
                }