diff --git a/NEWS b/NEWS index d1c1166ab05..b215bdfdca8 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,9 @@ PHP NEWS . Fixed bug GH-20329 (opcache.file_cache broken with full interned string buffer). (Arnaud) +- Standard: + . Fix memory leak in array_diff() with custom type checks. (ndossche) + - Tidy: . Fixed bug GH-20374 (PHP with tidy and custom-tags). (ndossche) diff --git a/ext/standard/array.c b/ext/standard/array.c index 13d17bff82c..c8417d96526 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -5889,6 +5889,7 @@ PHP_FUNCTION(array_diff) for (i = 1; i < argc; i++) { if (Z_TYPE(args[i]) != IS_ARRAY) { + zend_tmp_string_release(tmp_search_str); zend_argument_type_error(i + 1, "must be of type array, %s given", zend_zval_value_name(&args[i])); RETURN_THROWS(); } diff --git a/ext/standard/tests/array/array_diff_leak_custom_type_checks.phpt b/ext/standard/tests/array/array_diff_leak_custom_type_checks.phpt new file mode 100644 index 00000000000..77aef0ccc08 --- /dev/null +++ b/ext/standard/tests/array/array_diff_leak_custom_type_checks.phpt @@ -0,0 +1,14 @@ +--TEST-- +array_diff() memory leak with custom type checks +--FILE-- +getMessage(), "\n"; +} + +?> +--EXPECT-- +array_diff(): Argument #2 must be of type array, string given