Skip to content

Commit a0b918d

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix memory leak in array_diff() with custom type checks
2 parents 47cedfa + 43b232a commit a0b918d

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ PHP NEWS
55
- Core:
66
. Sync all boost.context files with release 1.86.0. (mvorisek)
77

8+
- Standard:
9+
. Fix memory leak in array_diff() with custom type checks. (ndossche)
10+
811
- Opcache:
912
. Fixed bug GH-20329 (opcache.file_cache broken with full interned string
1013
buffer). (Arnaud)

ext/standard/array.c

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

59035903
for (i = 1; i < argc; i++) {
59045904
if (Z_TYPE(args[i]) != IS_ARRAY) {
5905+
zend_tmp_string_release(tmp_search_str);
59055906
zend_argument_type_error(i + 1, "must be of type array, %s given", zend_zval_value_name(&args[i]));
59065907
RETURN_THROWS();
59075908
}
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)