Index: Zend/zend_vm_def.h =================================================================== RCS file: /repository/ZendEngine2/zend_vm_def.h,v retrieving revision 1.59.2.22 diff -u -p -d -r1.59.2.22 zend_vm_def.h --- Zend/zend_vm_def.h 4 Jan 2006 23:53:04 -0000 1.59.2.22 +++ Zend/zend_vm_def.h 3 Feb 2006 10:24:12 -0000 @@ -1684,14 +1684,14 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_ME zend_op *opline = EX(opline); zval *function_name; zend_class_entry *ce; + char *function_name_strval = NULL; + int function_name_strlen; + zend_bool is_const = (OP2_TYPE == IS_CONST); zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), NULL); ce = EX_T(opline->op1.u.var).class_entry; if(OP2_TYPE != IS_UNUSED) { - char *function_name_strval; - int function_name_strlen; - zend_bool is_const = (OP2_TYPE == IS_CONST); zend_free_op free_op2; if (is_const) { @@ -1710,12 +1710,14 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_ME EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); if (!is_const) { - efree(function_name_strval); FREE_OP2(); } } else { if(!ce->constructor) { zend_error_noreturn(E_ERROR, "Can not call constructor"); + } else { + function_name_strval = ce->constructor->common.function_name; + is_const = 1; /* prevent freeing of function_name_strval */ } EX(fbc) = ce->constructor; } @@ -1723,11 +1725,18 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_ME if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { + if (EG(This) && !instanceof_function(Z_OBJCE_P(EG(This)), ce)) { + zend_error(E_NOTICE, "Non-static method %s::%s() cannot be called statically", ce->name, function_name_strval); + } if ((EX(object) = EG(This))) { EX(object)->refcount++; } } + if (function_name_strval && !is_const) { + efree(function_name_strval); + } + ZEND_VM_NEXT_OPCODE(); } Index: Zend/zend_vm_execute.h =================================================================== RCS file: /repository/ZendEngine2/zend_vm_execute.h,v retrieving revision 1.62.2.23 diff -u -p -d -r1.62.2.23 zend_vm_execute.h --- Zend/zend_vm_execute.h 4 Jan 2006 23:53:04 -0000 1.62.2.23 +++ Zend/zend_vm_execute.h 3 Feb 2006 10:24:14 -0000 @@ -631,14 +631,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ zend_op *opline = EX(opline); zval *function_name; zend_class_entry *ce; + char *function_name_strval = NULL; + int function_name_strlen; + zend_bool is_const = (IS_CONST == IS_CONST); zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), NULL); ce = EX_T(opline->op1.u.var).class_entry; if(IS_CONST != IS_UNUSED) { - char *function_name_strval; - int function_name_strlen; - zend_bool is_const = (IS_CONST == IS_CONST); if (is_const) { @@ -657,12 +657,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); if (!is_const) { - efree(function_name_strval); } } else { if(!ce->constructor) { zend_error_noreturn(E_ERROR, "Can not call constructor"); + } else { + function_name_strval = ce->constructor->common.function_name; + is_const = 1; /* prevent freeing of function_name_strval */ } EX(fbc) = ce->constructor; } @@ -670,11 +672,18 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { + if (EG(This) && !instanceof_function(Z_OBJCE_P(EG(This)), ce)) { + zend_error(E_NOTICE, "Non-static method %s::%s() cannot be called statically", ce->name, function_name_strval); + } if ((EX(object) = EG(This))) { EX(object)->refcount++; } } + if (function_name_strval && !is_const) { + efree(function_name_strval); + } + ZEND_VM_NEXT_OPCODE(); } @@ -823,14 +832,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ zend_op *opline = EX(opline); zval *function_name; zend_class_entry *ce; + char *function_name_strval = NULL; + int function_name_strlen; + zend_bool is_const = (IS_TMP_VAR == IS_CONST); zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), NULL); ce = EX_T(opline->op1.u.var).class_entry; if(IS_TMP_VAR != IS_UNUSED) { - char *function_name_strval; - int function_name_strlen; - zend_bool is_const = (IS_TMP_VAR == IS_CONST); zend_free_op free_op2; if (is_const) { @@ -849,12 +858,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); if (!is_const) { - efree(function_name_strval); zval_dtor(free_op2.var); } } else { if(!ce->constructor) { zend_error_noreturn(E_ERROR, "Can not call constructor"); + } else { + function_name_strval = ce->constructor->common.function_name; + is_const = 1; /* prevent freeing of function_name_strval */ } EX(fbc) = ce->constructor; } @@ -862,11 +873,18 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { + if (EG(This) && !instanceof_function(Z_OBJCE_P(EG(This)), ce)) { + zend_error(E_NOTICE, "Non-static method %s::%s() cannot be called statically", ce->name, function_name_strval); + } if ((EX(object) = EG(This))) { EX(object)->refcount++; } } + if (function_name_strval && !is_const) { + efree(function_name_strval); + } + ZEND_VM_NEXT_OPCODE(); } @@ -972,14 +990,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ zend_op *opline = EX(opline); zval *function_name; zend_class_entry *ce; + char *function_name_strval = NULL; + int function_name_strlen; + zend_bool is_const = (IS_VAR == IS_CONST); zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), NULL); ce = EX_T(opline->op1.u.var).class_entry; if(IS_VAR != IS_UNUSED) { - char *function_name_strval; - int function_name_strlen; - zend_bool is_const = (IS_VAR == IS_CONST); zend_free_op free_op2; if (is_const) { @@ -998,12 +1016,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); if (!is_const) { - efree(function_name_strval); if (free_op2.var) {zval_ptr_dtor(&free_op2.var);}; } } else { if(!ce->constructor) { zend_error_noreturn(E_ERROR, "Can not call constructor"); + } else { + function_name_strval = ce->constructor->common.function_name; + is_const = 1; /* prevent freeing of function_name_strval */ } EX(fbc) = ce->constructor; } @@ -1011,11 +1031,18 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { + if (EG(This) && !instanceof_function(Z_OBJCE_P(EG(This)), ce)) { + zend_error(E_NOTICE, "Non-static method %s::%s() cannot be called statically", ce->name, function_name_strval); + } if ((EX(object) = EG(This))) { EX(object)->refcount++; } } + if (function_name_strval && !is_const) { + efree(function_name_strval); + } + ZEND_VM_NEXT_OPCODE(); } @@ -1120,14 +1147,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ zend_op *opline = EX(opline); zval *function_name; zend_class_entry *ce; + char *function_name_strval = NULL; + int function_name_strlen; + zend_bool is_const = (IS_UNUSED == IS_CONST); zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), NULL); ce = EX_T(opline->op1.u.var).class_entry; if(IS_UNUSED != IS_UNUSED) { - char *function_name_strval; - int function_name_strlen; - zend_bool is_const = (IS_UNUSED == IS_CONST); if (is_const) { @@ -1146,12 +1173,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); if (!is_const) { - efree(function_name_strval); } } else { if(!ce->constructor) { zend_error_noreturn(E_ERROR, "Can not call constructor"); + } else { + function_name_strval = ce->constructor->common.function_name; + is_const = 1; /* prevent freeing of function_name_strval */ } EX(fbc) = ce->constructor; } @@ -1159,11 +1188,18 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { + if (EG(This) && !instanceof_function(Z_OBJCE_P(EG(This)), ce)) { + zend_error(E_NOTICE, "Non-static method %s::%s() cannot be called statically", ce->name, function_name_strval); + } if ((EX(object) = EG(This))) { EX(object)->refcount++; } } + if (function_name_strval && !is_const) { + efree(function_name_strval); + } + ZEND_VM_NEXT_OPCODE(); } @@ -1201,14 +1237,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ zend_op *opline = EX(opline); zval *function_name; zend_class_entry *ce; + char *function_name_strval = NULL; + int function_name_strlen; + zend_bool is_const = (IS_CV == IS_CONST); zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), NULL); ce = EX_T(opline->op1.u.var).class_entry; if(IS_CV != IS_UNUSED) { - char *function_name_strval; - int function_name_strlen; - zend_bool is_const = (IS_CV == IS_CONST); if (is_const) { @@ -1227,12 +1263,14 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); if (!is_const) { - efree(function_name_strval); } } else { if(!ce->constructor) { zend_error_noreturn(E_ERROR, "Can not call constructor"); + } else { + function_name_strval = ce->constructor->common.function_name; + is_const = 1; /* prevent freeing of function_name_strval */ } EX(fbc) = ce->constructor; } @@ -1240,11 +1278,18 @@ static int ZEND_INIT_STATIC_METHOD_CALL_ if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { + if (EG(This) && !instanceof_function(Z_OBJCE_P(EG(This)), ce)) { + zend_error(E_NOTICE, "Non-static method %s::%s() cannot be called statically", ce->name, function_name_strval); + } if ((EX(object) = EG(This))) { EX(object)->refcount++; } } + if (function_name_strval && !is_const) { + efree(function_name_strval); + } + ZEND_VM_NEXT_OPCODE(); }