Skip to content

Commit 7289ce6

Browse files
committed
Fix memory leak of function attribute hash table
Found while implementing #7921: > ==56540== 272 (56 direct, 216 indirect) bytes in 1 blocks are definitely lost in loss record 8 of 8 > ==56540== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) > ==56540== by 0x6D2C62: __zend_malloc (zend_alloc.c:3055) > ==56540== by 0x73E874: zend_add_attribute (zend_attributes.c:282) > ==56540== by 0x65BE40: zend_add_parameter_attribute (zend_attributes.h:104) > ==56540== by 0x65C760: zm_startup_password (password.c:452) > ==56540== by 0x592AC7: zm_startup_basic (basic_functions.c:364) > ==56540== by 0x71B18D: zend_startup_module_ex (zend_API.c:2202) > ==56540== by 0x71B1EC: zend_startup_module_zval (zend_API.c:2217) > ==56540== by 0x72CF48: zend_hash_apply (zend_hash.c:2011) > ==56540== by 0x71B8F0: zend_startup_modules (zend_API.c:2328) > ==56540== by 0x66CE1B: php_module_startup (main.c:2256) > ==56540== by 0x887FC8: php_cli_startup (php_cli.c:409)
1 parent 05023a2 commit 7289ce6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/zend_opcode.c

+6
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ ZEND_API void zend_function_dtor(zval *zv)
153153
ZEND_ASSERT(function->common.function_name);
154154
zend_string_release_ex(function->common.function_name, 1);
155155

156+
if (function->common.attributes) {
157+
zend_hash_destroy(function->common.attributes);
158+
free(function->common.attributes);
159+
function->common.attributes = NULL;
160+
}
161+
156162
/* For methods this will be called explicitly. */
157163
if (!function->common.scope) {
158164
zend_free_internal_arg_info(&function->internal_function);

0 commit comments

Comments
 (0)