Skip to content

Commit

Permalink
"::class" Feature
Browse files Browse the repository at this point in the history
* Fixed memory leak by adding zval_dtor() on class_name in zend_compile.c's zend_resolve_class_name()
  • Loading branch information
ralphschindler committed Sep 10, 2012
1 parent 26d592a commit 41a10e7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Zend/zend_compile.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2172,9 +2172,9 @@ void zend_resolve_class_name(znode *class_name, ulong fetch_type, int check_ns_n
if (!CG(active_class_entry)) { if (!CG(active_class_entry)) {
zend_error(E_COMPILE_ERROR, "Cannot access self::class when no class scope is active"); zend_error(E_COMPILE_ERROR, "Cannot access self::class when no class scope is active");
} }
tmp.op_type = IS_CONST; zval_dtor(&class_name->u.constant);
ZVAL_STRINGL(&tmp.u.constant, CG(active_class_entry)->name, strlen(CG(active_class_entry)->name), 1); class_name->op_type = IS_CONST;
*class_name = tmp; ZVAL_STRINGL(&class_name->u.constant, CG(active_class_entry)->name, CG(active_class_entry)->name_length, 1);
break; break;
case ZEND_FETCH_CLASS_STATIC: case ZEND_FETCH_CLASS_STATIC:
if (!CG(active_class_entry)) { if (!CG(active_class_entry)) {
Expand All @@ -2184,6 +2184,7 @@ void zend_resolve_class_name(znode *class_name, ulong fetch_type, int check_ns_n
if (!CG(active_class_entry)) { if (!CG(active_class_entry)) {
zend_error(E_COMPILE_ERROR, "Cannot access parent::class when no class scope is active"); zend_error(E_COMPILE_ERROR, "Cannot access parent::class when no class scope is active");
} }
zval_dtor(&class_name->u.constant);
opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_DO_FCALL; opline->opcode = ZEND_DO_FCALL;
opline->result.var = get_temporary_variable(CG(active_op_array)); opline->result.var = get_temporary_variable(CG(active_op_array));
Expand Down

0 comments on commit 41a10e7

Please sign in to comment.