FREE_OP(Ts, op2, EG(free_op2));
if (&EX(opline)->result) {
- EX_T(EX(opline)->result.u.var).var.ptr = retval;
- EX_T(EX(opline)->result.u.var).var.ptr_ptr = NULL;/*&EX_T(EX(opline)->result.u.var).var.ptr;*/
- SELECTIVE_PZVAL_LOCK(retval, &EX(opline)->result);
+ if (retval->refcount < 2) {
+ zend_error(E_WARNING, "Method %s::set() did not return a value, using input value", obj_ce->name);
+ EX_T(EX(opline)->result.u.var).var.ptr = value;
+ SELECTIVE_PZVAL_LOCK(value, &EX(opline)->result);
+ DELETE_RET_ZVAL(retval);
+ } else {
+ EX_T(EX(opline)->result.u.var).var.ptr = retval;
+ retval->refcount--;
+ }
+ EX_T(EX(opline)->result.u.var).var.ptr_ptr = NULL;
+ } else {
+ DELETE_RET_ZVAL(retval);
}
EX(opline)++;
int(4)
c::exists(5th)
-Notice: Undefined index: 5th in %s on line %d
+Notice: Undefined index: 5th in %sarray_access_001.php on line %d
NULL
c::exists(6)
-Notice: Undefined index: 6 in %s on line %d
+Notice: Undefined index: 6 in %sarray_access_001.php on line %d
NULL
WRITE 1
-c::exists(1)
c::set(1,Changed 1)
c::exists(1)
c::get(1)
string(9) "Changed 1"
WRITE 2
-c::exists(4th)
c::set(4th,Changed 4th)
c::exists(4th)
c::get(4th)
string(11) "Changed 4th"
WRITE 3
-c::exists(5th)
c::set(5th,Added 5th)
c::exists(5th)
c::get(5th)
string(9) "Added 5th"
WRITE 4
-c::exists(6)
c::set(6,Added 6)
c::exists(6)
c::get(6)
c::exists(2)
c::get(2)
string(3) "3rd"
-c::exists(6)
c::set(6,changed 6)
c::exists(6)
c::get(6)
class c implements spl_array_access {
public $a = array('1st', 1, 2=>'3rd', '4th'=>4);
+
function exists($index) {
echo __METHOD__ . "($index)\n";
return array_key_exists($index, $this->a);
int(4)
c::exists(5th)
-Notice: Undefined index: 5th in %s on line %d
+Notice: Undefined index: 5th in %sarray_access_002.php on line %d
NULL
c::exists(6)
-Notice: Undefined index: 6 in %s on line %d
+Notice: Undefined index: 6 in %sarray_access_002.php on line %d
NULL
WRITE 1
-c::exists(1)
c::set(1,Changed 1)
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d
c::exists(1)
c::get(1)
string(9) "Changed 1"
WRITE 2
-c::exists(4th)
c::set(4th,Changed 4th)
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d
c::exists(4th)
c::get(4th)
string(11) "Changed 4th"
WRITE 3
-c::exists(5th)
c::set(5th,Added 5th)
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d
c::exists(5th)
c::get(5th)
string(9) "Added 5th"
WRITE 4
-c::exists(6)
c::set(6,Added 6)
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d
c::exists(6)
c::get(6)
string(7) "Added 6"
c::exists(2)
c::get(2)
string(3) "3rd"
-c::exists(6)
c::set(6,changed 6)
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d
c::exists(6)
c::get(6)
string(9) "changed 6"
-NULL
+string(9) "changed 6"
Done