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

index 3b8195c96447a14d1823f5b7c368851c192ab65a..41187efe47dc53d2b3af5e4ac14bc23a4d32dfc5 100644 (file)
@@ -4555,6 +4555,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..646eb76
--- /dev/null
@@ -0,0 +1,23 @@
+--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