]> granicus.if.org Git - php/commitdiff
plug leak on error (coverity issue #405)
authorAntony Dovgal <tony2001@php.net>
Fri, 21 Sep 2007 13:50:47 +0000 (13:50 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 21 Sep 2007 13:50:47 +0000 (13:50 +0000)
ext/standard/array.c
ext/standard/tests/array/array_map_001.phpt [new file with mode: 0644]

index 68616f11883903825db05cb20ea3232afebf07f6..8becac62c7de990fa1af28486e9301a79b4a1a39 100644 (file)
@@ -4477,6 +4477,8 @@ PHP_FUNCTION(array_map)
                                efree(args);
                                efree(array_pos);
                                zval_dtor(return_value);
+                               zval_ptr_dtor(&null);
+                               efree(params);
                                RETURN_NULL();
                        }
                }
diff --git a/ext/standard/tests/array/array_map_001.phpt b/ext/standard/tests/array/array_map_001.phpt
new file mode 100644 (file)
index 0000000..e4dd279
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+array_map() and exceptions in the callback
+--FILE--
+<?php
+
+$a = array(1,2,3);
+
+function foo() { 
+       throw new exception(1); 
+} 
+
+try { 
+       array_map("foo", $a, array(2,3)); 
+} catch (Exception $e) {
+       var_dump("exception caught!");
+}
+
+echo "Done\n";
+?>
+--EXPECTF--    
+Warning: array_map(): An error occurred while invoking the map callback in %s on line %d
+string(17) "exception caught!"
+Done
+--UEXPECTF--
+Warning: array_map(): An error occurred while invoking the map callback in %s on line %d
+unicode(17) "exception caught!"
+Done