Fix bug #67858: Leak when $php_errormsg already set

This commit is contained in:
Nikita Popov 2014-08-18 18:12:50 +02:00
parent eda5d30be9
commit 26a9dc3e04
2 changed files with 20 additions and 0 deletions

19
Zend/tests/bug67858.phpt Normal file
View File

@ -0,0 +1,19 @@
--TEST--
Bug #67858: Leak when $php_errormsg already set
--INI--
track_errors=1
error_reporting=E_ALL
--FILE--
<?php
function f() {
$php_errormsg = [1, 2, 3];
echo $var;
var_dump($php_errormsg);
}
f();
?>
--EXPECTF--
Notice: Undefined variable: var in %s on line %d
string(23) "Undefined variable: var"

View File

@ -1724,6 +1724,7 @@ ZEND_API int zend_set_local_var_str(const char *name, int len, zval *value, int
if (op_array->vars[i]->h == h &&
op_array->vars[i]->len == len &&
memcmp(op_array->vars[i]->val, name, len) == 0) {
zval_ptr_dtor(EX_VAR_NUM(i));
ZVAL_COPY_VALUE(EX_VAR_NUM(i), value);
return SUCCESS;
}