]> granicus.if.org Git - php/commitdiff
Fixed memory leak
authorDmitry Stogov <dmitry@php.net>
Thu, 14 Feb 2008 08:46:08 +0000 (08:46 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 14 Feb 2008 08:46:08 +0000 (08:46 +0000)
ext/standard/array.c
ext/standard/tests/array/array_push_variation4.phpt

index f809c91ff3e094ef61bcb1bce9e2fd3d9e94f494..f4431ed9ebf6da11c091b9a03ebe3f2ec80936f3 100644 (file)
@@ -1975,6 +1975,7 @@ PHP_FUNCTION(array_push)
                new_var->refcount++;
        
                if (zend_hash_next_index_insert(Z_ARRVAL_P(stack), &new_var, sizeof(zval *), NULL) == FAILURE) {
+                       new_var->refcount--;
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot add element to the array as the next element is already occupied");
                        efree(args);
                        RETURN_FALSE;
index 5bb20f32c688c1f19a94b57b0644688ff6a1f4ea..2d02fa93ff2cd4da425f97c048c3e4dacd2fa97b 100644 (file)
@@ -32,6 +32,9 @@ echo "\n-- Pass \$var argument which is a reference to \$stack argument --\n";
 var_dump(array_push($array, &$array));
 var_dump($array);
 
+/* break cycle */
+$array[9] = null;
+
 echo "Done";
 ?>
 --EXPECTF--