Skip to content

Commit

Permalink
Remove double intern
Browse files Browse the repository at this point in the history
The name is already interned in uopz_add_function(). If interning
fails, this could end up releasing the string.
  • Loading branch information
nikic committed Jul 29, 2021
1 parent f871da0 commit 592ae76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/function.c
Expand Up @@ -38,7 +38,7 @@ static zend_function* uopz_copy_function(zend_class_entry *scope, zend_string *n

copy->op_array.fn_flags &= ~ZEND_ACC_CLOSURE|ZEND_ACC_IMMUTABLE|ZEND_ACC_ARENA_ALLOCATED;

copy->op_array.function_name = zend_new_interned_string(name);
copy->op_array.function_name = zend_string_copy(name);

copy->op_array.scope = scope;

Expand Down
5 changes: 5 additions & 0 deletions tests/012.phpt
Expand Up @@ -76,6 +76,11 @@ try {
} catch (Exception $e) {
var_dump($e->getMessage());
}

$foo = "foo";
uopz_add_function($foo . "bar", function() {});
foobar();

?>
--EXPECTF--
string(%d) "__construct"
Expand Down

0 comments on commit 592ae76

Please sign in to comment.