summaryrefslogtreecommitdiff
path: root/Zend/zend_opcode.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2012-09-05 09:58:22 +0400
committerDmitry Stogov <dmitry@zend.com>2012-09-05 09:58:22 +0400
commit6c0508f8d5d5a62adb37a76bc682c94540199ee3 (patch)
treed43c860548c7dbfd5901945951bb28e7e68eb03e /Zend/zend_opcode.c
parentff0aa24054c166de64993ef608ccbb8486c64ba5 (diff)
downloadphp-git-6c0508f8d5d5a62adb37a76bc682c94540199ee3.tar.gz
Fixed bug #62907 (Double free when use traits)
Diffstat (limited to 'Zend/zend_opcode.c')
-rw-r--r--Zend/zend_opcode.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 19fd71e763..6eab0ae309 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -267,6 +267,15 @@ void _destroy_zend_class_traits_info(zend_class_entry *ce)
}
}
+static int zend_clear_trait_method_name(zend_op_array *op_array TSRMLS_DC)
+{
+ if (op_array->function_name && (op_array->fn_flags & ZEND_ACC_ALIAS) == 0) {
+ efree(op_array->function_name);
+ op_array->function_name = NULL;
+ }
+ return 0;
+}
+
ZEND_API void destroy_zend_class(zend_class_entry **pce)
{
zend_class_entry *ce = *pce;
@@ -298,6 +307,9 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce)
}
zend_hash_destroy(&ce->properties_info);
str_efree(ce->name);
+ if ((ce->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) {
+ zend_hash_apply(&ce->function_table, (apply_func_t)zend_clear_trait_method_name TSRMLS_CC);
+ }
zend_hash_destroy(&ce->function_table);
zend_hash_destroy(&ce->constants_table);
if (ce->num_interfaces > 0 && ce->interfaces) {
@@ -387,7 +399,7 @@ ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC)
}
efree(op_array->opcodes);
- if (op_array->function_name) {
+ if (op_array->function_name && (op_array->fn_flags & ZEND_ACC_ALIAS) == 0) {
efree((char*)op_array->function_name);
}
if (op_array->doc_comment) {