Skip to content

Bugfix for bug #49348 #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Zend/tests/bug52041.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,30 @@ Notice: Undefined variable: x in %sbug52041.php on line 3

Warning: Creating default object from empty value in %sbug52041.php on line 8

Notice: Undefined property: a in %sbug52041.php on line 8

Notice: Undefined variable: x in %sbug52041.php on line 3

Notice: Undefined property: a in %sbug52041.php on line 9

Warning: Creating default object from empty value in %sbug52041.php on line 9

Notice: Undefined property: b in %sbug52041.php on line 9

Notice: Undefined variable: x in %sbug52041.php on line 3

Warning: Creating default object from empty value in %sbug52041.php on line 10

Notice: Undefined property: a in %sbug52041.php on line 10

Notice: Undefined variable: x in %sbug52041.php on line 3

Notice: Undefined property: a in %sbug52041.php on line 11

Warning: Creating default object from empty value in %sbug52041.php on line 11

Notice: Undefined property: b in %sbug52041.php on line 11

Notice: Undefined variable: x in %sbug52041.php on line 3

Notice: Undefined variable: x in %sbug52041.php on line 3
Expand Down
8 changes: 5 additions & 3 deletions Zend/tests/bug60536_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@ Bug #60536 (Traits Segfault)
--FILE--
<?php
trait T { private $x = 0; }
class X {
class X {
use T;
}
class Y extends X {
use T;
function x() {
return ++$this->x;
return ++$this->x;
}
}
class Z extends Y {
function z() {
return ++$this->x;
return ++$this->x;
}
}
$a = new Z();
$a->x();
echo "DONE";
?>
--EXPECTF--

Notice: Undefined property: x in %s on line 14
DONE
2 changes: 2 additions & 0 deletions Zend/tests/bug62005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ function add_points($player, $points) {
add_points(NULL, 2);
--EXPECTF--
Warning: Creating default object from empty value in %sbug62005.php on line %d

Notice: Undefined property: energy in %sbug62005.php on line 3
stdClass Object
(
[energy] => 2
Expand Down
16 changes: 8 additions & 8 deletions Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
Expand Down Expand Up @@ -88,7 +88,7 @@ ZEND_METHOD(Closure, bind)
RETURN_NULL();
}

closure = (zend_closure *)zend_object_store_get_object(zclosure TSRMLS_CC);
closure = (zend_closure *)zend_object_store_get_object(zclosure TSRMLS_CC);

if ((newthis != NULL) && (closure->func.common.fn_flags & ZEND_ACC_STATIC)) {
zend_error(E_WARNING, "Cannot bind an instance to a static closure");
Expand Down Expand Up @@ -152,7 +152,7 @@ static int zend_closure_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */

ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC) /* {{{ */
{
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);
zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function));

invoke->common = closure->func.common;
Expand All @@ -168,14 +168,14 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC) /* {

ZEND_API const zend_function *zend_get_closure_method_def(zval *obj TSRMLS_DC) /* {{{ */
{
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);
return &closure->func;
}
/* }}} */

ZEND_API zval* zend_get_closure_this_ptr(zval *obj TSRMLS_DC) /* {{{ */
{
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);
return closure->this_ptr;
}
/* }}} */
Expand Down Expand Up @@ -212,7 +212,7 @@ static void zend_closure_write_property(zval *object, zval *member, zval *value,
}
/* }}} */

static zval **zend_closure_get_property_ptr_ptr(zval *object, zval *member, const zend_literal *key TSRMLS_DC) /* {{{ */
static zval **zend_closure_get_property_ptr_ptr(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */
{
ZEND_CLOSURE_PROPERTY_ERROR();
return NULL;
Expand Down Expand Up @@ -378,7 +378,7 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp TSRMLS_

static HashTable *zend_closure_get_gc(zval *obj, zval ***table, int *n TSRMLS_DC) /* {{{ */
{
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);

*table = closure->this_ptr ? &closure->this_ptr : NULL;
*n = closure->this_ptr ? 1 : 0;
Expand Down Expand Up @@ -474,7 +474,7 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent
zend_error(E_WARNING, "Cannot bind function %s::%s to scope class %s", func->common.scope->name, func->common.function_name, scope->name);
scope = NULL;
}
if(scope && this_ptr && (func->common.fn_flags & ZEND_ACC_STATIC) == 0 &&
if(scope && this_ptr && (func->common.fn_flags & ZEND_ACC_STATIC) == 0 &&
!instanceof_function(Z_OBJCE_P(this_ptr), closure->func.common.scope TSRMLS_CC)) {
zend_error(E_WARNING, "Cannot bind function %s::%s to object of class %s", func->common.scope->name, func->common.function_name, Z_OBJCE_P(this_ptr)->name);
scope = NULL;
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ static void zend_fetch_property_address(temp_variable *result, zval **container_
}

if (Z_OBJ_HT_P(container)->get_property_ptr_ptr) {
zval **ptr_ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, key TSRMLS_CC);
zval **ptr_ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, key TSRMLS_CC);
if (NULL == ptr_ptr) {
zval *ptr;

Expand Down Expand Up @@ -1523,9 +1523,9 @@ void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
}
/* }}} */

/*
/*
* Stack Frame Layout (the whole stack frame is allocated at once)
* ==================
* ==================
*
* +========================================+
* | zend_execute_data |<---+
Expand Down
6 changes: 4 additions & 2 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ static int zend_std_has_dimension(zval *object, zval *offset, int check_empty TS
}
/* }}} */

static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member, const zend_literal *key TSRMLS_DC) /* {{{ */
static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */
{
zend_object *zobj;
zval tmp_member;
Expand Down Expand Up @@ -754,7 +754,9 @@ static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member, const ze
/* we don't have access controls - will just add it */
new_zval = &EG(uninitialized_zval);

/* zend_error(E_NOTICE, "Undefined property: %s", Z_STRVAL_P(member)); */
if(UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
zend_error(E_NOTICE, "Undefined property: %s", Z_STRVAL_P(member));
}
Z_ADDREF_P(new_zval);
if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) &&
property_info->offset >= 0) {
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_object_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *


/* Used to create pointer to the property of the object, for future direct r/w access */
typedef zval **(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member, const struct _zend_literal *key TSRMLS_DC);
typedef zval **(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member, int type, const struct _zend_literal *key TSRMLS_DC);

/* Used to set object value. Can be used to override assignments and scalar
write ops (like ++, +=) on the object */
Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMP|VAR
/* here property is a string */
if (opline->extended_value == ZEND_ASSIGN_OBJ
&& Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
if (zptr != NULL) { /* NULL means no success in getting PTR */
SEPARATE_ZVAL_IF_NOT_REF(zptr);

Expand Down Expand Up @@ -625,7 +625,7 @@ ZEND_VM_HELPER_EX(zend_pre_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR|
}

if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
if (zptr != NULL) { /* NULL means no success in getting PTR */
SEPARATE_ZVAL_IF_NOT_REF(zptr);

Expand Down Expand Up @@ -726,7 +726,7 @@ ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR
}

if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
if (zptr != NULL) { /* NULL means no success in getting PTR */
have_get_ptr = 1;
SEPARATE_ZVAL_IF_NOT_REF(zptr);
Expand Down Expand Up @@ -5411,7 +5411,7 @@ ZEND_VM_HANDLER(162, ZEND_FAST_CALL, ANY, ANY)
USE_OPLINE

if (opline->extended_value &&
UNEXPECTED(EG(prev_exception) != NULL)) {
UNEXPECTED(EG(prev_exception) != NULL)) {
/* in case of unhandled exception jump to catch block instead of finally */
ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]);
ZEND_VM_CONTINUE();
Expand Down
Loading