Skip to content

Commit 376fdd7

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix memory leak in array_diff() with custom type checks
2 parents cf96153 + a0b918d commit 376fdd7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

ext/standard/array.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5909,6 +5909,7 @@ PHP_FUNCTION(array_diff)
59095909

59105910
for (i = 1; i < argc; i++) {
59115911
if (Z_TYPE(args[i]) != IS_ARRAY) {
5912+
zend_tmp_string_release(tmp_search_str);
59125913
zend_argument_type_error(i + 1, "must be of type array, %s given", zend_zval_value_name(&args[i]));
59135914
RETURN_THROWS();
59145915
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
array_diff() memory leak with custom type checks
3+
--FILE--
4+
<?php
5+
6+
try {
7+
array_diff([123], 'x');
8+
} catch (TypeError $e) {
9+
echo $e->getMessage(), "\n";
10+
}
11+
12+
?>
13+
--EXPECT--
14+
array_diff(): Argument #2 must be of type array, string given

0 commit comments

Comments
 (0)