cvs: ZendEngine2(PHP_5_3) / zend_object_handlers.c /tests bug48215_2.phpt

[email protected] ("Scott MacVicar") Fri, 19 Jun 2009 03:29:48 -0000
Newsgroups php.zend-engine.cvs
Message-ID <cvsscottmac1245382188@cvsserver>
scottmac		Fri Jun 19 03:29:48 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /ZendEngine2/tests	bug48215_2.phpt 

  Modified files:              
    /ZendEngine2	zend_object_handlers.c 
  Log:
  Make the check case sensitive, and since we can only have a constructor that matches the class name or is __construct
  its probably safe to just check for __. This means we can skip lowering the function_name, which is hard to be binary
  safe sine we don't store the length.
  
  If we just did a zend_hash_exists lookup we'd be fine since its stored lowercased already :)
  
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.135.2.6.2.22.2.30&r2=1.135.2.6.2.22.2.31&diff_format=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.30 ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.31
--- ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.30	Thu Jun 18 13:46:16 2009
+++ ZendEngine2/zend_object_handlers.c	Fri Jun 19 03:29:47 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_object_handlers.c,v 1.135.2.6.2.22.2.30 2009/06/18 13:46:16 scottmac Exp $ */
+/* $Id: zend_object_handlers.c,v 1.135.2.6.2.22.2.31 2009/06/19 03:29:47 scottmac Exp $ */
 
 #include "zend.h"
 #include "zend_globals.h"
@@ -942,8 +942,10 @@
 
 	if (function_name_strlen == ce->name_length && ce->constructor) {
 		lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length);
-		/* Only change the method to the constructor if a __construct() method doesn't exist */
-		if (!memcmp(lc_class_name, function_name_strval, function_name_strlen) && memcmp(ce->constructor->common.function_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {
+		/* Only change the method to the constructor if the constructor isn't called __construct
+		 * we check for __ so we can be binary safe for lowering, we should use ZEND_CONSTRUCTOR_FUNC_NAME
+		 */
+		if (!memcmp(lc_class_name, function_name_strval, function_name_strlen) && memcmp(ce->constructor->common.function_name, "__", sizeof("__") - 1)) {
 			fbc = ce->constructor;
 		}
 		efree(lc_class_name);

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug48215_2.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug48215_2.phpt
+++ ZendEngine2/tests/bug48215_2.phpt