mirror of
https://github.com/php/php-src.git
synced 2025-01-22 19:54:13 +08:00
- MFH: Fixed bug #46160 (SPL - Memory leak when exception is throwed in offsetSet method)
This commit is contained in:
parent
169e68ed1a
commit
54231ab577
@ -818,6 +818,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;
|
||||
}
|
||||
@ -840,6 +841,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;
|
||||
}
|
||||
|
14
ext/spl/tests/bug46160.phpt
Normal file
14
ext/spl/tests/bug46160.phpt
Normal file
@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
Bug #46160 (SPL - Memory leak when exception is throwed in offsetSet method)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
try {
|
||||
$x = new splqueue;
|
||||
$x->offsetSet(0, 0);
|
||||
} catch (Exception $e) { }
|
||||
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
DONE
|
Loading…
Reference in New Issue
Block a user