Skip to content

Commit e461c22

Browse files
committed
Fixed memory leaks (related to bug #52361)
1 parent 0ff6f90 commit e461c22

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Zend/zend_exceptions.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void zend_exception_restore(TSRMLS_D) /* {{{ */
8181
}
8282
/* }}} */
8383

84-
void zend_throw_exception_internal(zval *exception TSRMLS_DC) /* {{{ */
84+
ZEND_API void zend_throw_exception_internal(zval *exception TSRMLS_DC) /* {{{ */
8585
{
8686
#ifdef HAVE_DTRACE
8787
if (DTRACE_EXCEPTION_THROWN_ENABLED()) {
@@ -580,6 +580,7 @@ ZEND_METHOD(exception, __toString)
580580
zend_call_function(&fci, NULL TSRMLS_CC);
581581

582582
if (Z_TYPE_P(trace) != IS_STRING) {
583+
zval_ptr_dtor(&trace);
583584
trace = NULL;
584585
}
585586

@@ -600,17 +601,18 @@ ZEND_METHOD(exception, __toString)
600601
zval_dtor(&line);
601602

602603
exception = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 0 TSRMLS_CC);
604+
605+
if (trace) {
606+
zval_ptr_dtor(&trace);
607+
}
608+
603609
}
604610
zval_dtor(&fname);
605611

606612
/* We store the result in the private property string so we can access
607613
* the result in uncaught exception handlers without memleaks. */
608614
zend_update_property_string(default_exception_ce, getThis(), "string", sizeof("string")-1, str TSRMLS_CC);
609615

610-
if (trace) {
611-
zval_ptr_dtor(&trace);
612-
}
613-
614616
RETURN_STRINGL(str, len, 0);
615617
}
616618
/* }}} */

0 commit comments

Comments
 (0)