mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-20043: array_unique assertion failure with RC1 array causing an exception on sort
This commit is contained in:
2
NEWS
2
NEWS
@@ -60,6 +60,8 @@ PHP NEWS
|
||||
. Fixed bug GH-19701 (Serialize/deserialize loses some data). (nielsdos)
|
||||
. Fixed bug GH-19801 (leaks in var_dump() and debug_zval_dump()).
|
||||
(alexandre-daubois)
|
||||
. Fixed bug GH-20043 (array_unique assertion failure with RC1 array
|
||||
causing an exception on sort). (nielsdos)
|
||||
|
||||
- Streams:
|
||||
. Fixed bug GH-19248 (Use strerror_r instead of strerror in main).
|
||||
|
||||
@@ -5027,6 +5027,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++) {
|
||||
@@ -5046,6 +5051,8 @@ PHP_FUNCTION(array_unique)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
pefree(arTmp, GC_FLAGS(Z_ARRVAL_P(array)) & IS_ARRAY_PERSISTENT);
|
||||
|
||||
if (in_place) {
|
||||
|
||||
12
ext/standard/tests/array/gh20043.phpt
Normal file
12
ext/standard/tests/array/gh20043.phpt
Normal 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
|
||||
Reference in New Issue
Block a user