]> granicus.if.org Git - php/commitdiff
MFH: fix #40784 (Case sensivity in constructor's fallback)
authorAntony Dovgal <tony2001@php.net>
Mon, 12 Mar 2007 13:10:40 +0000 (13:10 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 12 Mar 2007 13:10:40 +0000 (13:10 +0000)
Zend/tests/bug40784.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/Zend/tests/bug40784.phpt b/Zend/tests/bug40784.phpt
new file mode 100644 (file)
index 0000000..6da8f2a
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Bug #40784 (Case sensivity in constructor's fallback)
+--FILE--
+<?php
+
+class A {
+         function A () { echo "I'm A\n"; }
+}
+
+class B extends A {
+  function __construct() {
+    parent::__construct();
+    parent::__constrUct();
+  }
+}
+
+$b = new B;
+
+echo "Done\n";
+?>
+--EXPECTF--    
+I'm A
+I'm A
+Done
index 8f21d5f250c16a72f2e52d64c0aab4b2fcbc0852..ff2963d921db0f50d3c1beb5e1a24bd66f8db002 100644 (file)
@@ -1480,12 +1480,15 @@ void zend_do_begin_class_member_function_call(znode *class_name, znode *method_n
        opline->op2 = *method_name;
 
        if (opline->op2.op_type == IS_CONST) {
+               char *lcname = zend_str_tolower_dup(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant));
                if ((sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == Z_STRLEN(opline->op2.u.constant) &&
-                   memcmp(Z_STRVAL(opline->op2.u.constant), ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == 0) {
+                   memcmp(lcname, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) == 0) {
                        zval_dtor(&opline->op2.u.constant);
                        SET_UNUSED(opline->op2);
+                       efree(lcname);
                } else {
-                       zend_str_tolower(opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len);
+                       efree(opline->op2.u.constant.value.str.val);
+                       opline->op2.u.constant.value.str.val = lcname;
                }
        }