]> granicus.if.org Git - php/commitdiff
- Fixed bug #46160 (SPL - Memory leak when exception is throwed in offsetSet method)
authorFelipe Pena <felipe@php.net>
Tue, 23 Sep 2008 12:05:02 +0000 (12:05 +0000)
committerFelipe Pena <felipe@php.net>
Tue, 23 Sep 2008 12:05:02 +0000 (12:05 +0000)
ext/spl/spl_dllist.c
ext/spl/tests/bug46160.phpt [new file with mode: 0644]

index 560f1883725d5b0179aadc49d93ffb76e50683f0..2b457020d6cf16c97ce92cce2dfe76d5b45db34e 100644 (file)
@@ -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 (file)
index 0000000..e4dbdff
--- /dev/null
@@ -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