1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4' into PHP-8.5

* PHP-8.4:
  Fix GH-20043: array_unique assertion failure with RC1 array causing an exception on sort
This commit is contained in:
Niels Dossche
2025-10-05 20:16:12 +02:00
2 changed files with 19 additions and 0 deletions

View File

@@ -5044,6 +5044,11 @@ PHP_FUNCTION(array_unique)
ZVAL_UNDEF(&arTmp[i].b.val);
zend_sort((void *) arTmp, i, sizeof(struct bucketindex),
(compare_func_t) cmp, (swap_func_t) array_bucketindex_swap);
if (UNEXPECTED(EG(exception))) {
goto out;
}
/* go through the sorted array and delete duplicates from the copy */
lastkept = arTmp;
for (cmpdata = arTmp + 1; Z_TYPE(cmpdata->b.val) != IS_UNDEF; cmpdata++) {
@@ -5063,6 +5068,8 @@ PHP_FUNCTION(array_unique)
}
}
}
out:
pefree(arTmp, GC_FLAGS(Z_ARRVAL_P(array)) & IS_ARRAY_PERSISTENT);
if (in_place) {

View File

@@ -0,0 +1,12 @@
--TEST--
GH-20043 (array_unique assertion failure with RC1 array causing an exception on sort)
--FILE--
<?php
try {
array_unique([new stdClass, new stdClass], SORT_STRING | SORT_FLAG_CASE);
} catch (Error $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Object of class stdClass could not be converted to string