From: Felipe Pena Date: Tue, 23 Sep 2008 12:05:02 +0000 (+0000) Subject: - Fixed bug #46160 (SPL - Memory leak when exception is throwed in offsetSet method) X-Git-Tag: BEFORE_HEAD_NS_CHANGE~339 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a0956cf09f9da34232dad8aec8b8f581a21d714;p=php - Fixed bug #46160 (SPL - Memory leak when exception is throwed in offsetSet method) --- diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 560f188372..2b457020d6 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -816,6 +816,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet) index = spl_offset_convert_to_long(zindex TSRMLS_CC); if (index < 0 || index >= intern->llist->count) { + zval_ptr_dtor(&value); zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid or out of range", 0 TSRMLS_CC); return; } @@ -838,6 +839,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet) intern->llist->ctor(element TSRMLS_CC); } } else { + zval_ptr_dtor(&value); zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid", 0 TSRMLS_CC); return; } diff --git a/ext/spl/tests/bug46160.phpt b/ext/spl/tests/bug46160.phpt new file mode 100644 index 0000000000..e4dbdff192 --- /dev/null +++ b/ext/spl/tests/bug46160.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #46160 (SPL - Memory leak when exception is throwed in offsetSet method) +--FILE-- +offsetSet(0, 0); +} catch (Exception $e) { } + +?> +DONE +--EXPECT-- +DONE