]> granicus.if.org Git - php/commitdiff
fix memory leak
authorXinchen Hui <laruence@php.net>
Thu, 21 Mar 2013 02:56:30 +0000 (10:56 +0800)
committerXinchen Hui <laruence@php.net>
Thu, 21 Mar 2013 02:58:58 +0000 (10:58 +0800)
the value shouldn't be ref, use z_add_ref is enough

ext/spl/spl_dllist.c

index 83610863e42a3355672e45fd6164f375b2e3a217..aa462dfd764602db8255134aa8096b6bb3cb5f69 100644 (file)
@@ -1246,7 +1246,6 @@ SPL_METHOD(SplDoublyLinkedList, add)
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &zindex, &value) == FAILURE) {
                return;
        }
-       SEPARATE_ARG_IF_REF(value);
 
        intern = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        index  = spl_offset_convert_to_long(zindex TSRMLS_CC);
@@ -1256,6 +1255,7 @@ SPL_METHOD(SplDoublyLinkedList, add)
                return;
        }
 
+       Z_ADDREF_P(value);
        if (index == intern->llist->count) {
                /* If index is the last entry+1 then we do a push because we're not inserting before any entry */
                spl_ptr_llist_push(intern->llist, value TSRMLS_CC);