File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -5044,6 +5044,11 @@ PHP_FUNCTION(array_unique)
5044
5044
ZVAL_UNDEF (& arTmp [i ].b .val );
5045
5045
zend_sort ((void * ) arTmp , i , sizeof (struct bucketindex ),
5046
5046
(compare_func_t ) cmp , (swap_func_t ) array_bucketindex_swap );
5047
+
5048
+ if (UNEXPECTED (EG (exception ))) {
5049
+ goto out ;
5050
+ }
5051
+
5047
5052
/* go through the sorted array and delete duplicates from the copy */
5048
5053
lastkept = arTmp ;
5049
5054
for (cmpdata = arTmp + 1 ; Z_TYPE (cmpdata -> b .val ) != IS_UNDEF ; cmpdata ++ ) {
@@ -5063,6 +5068,8 @@ PHP_FUNCTION(array_unique)
5063
5068
}
5064
5069
}
5065
5070
}
5071
+
5072
+ out :
5066
5073
pefree (arTmp , GC_FLAGS (Z_ARRVAL_P (array )) & IS_ARRAY_PERSISTENT );
5067
5074
5068
5075
if (in_place ) {
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-20043 (array_unique assertion failure with RC1 array causing an exception on sort)
3
+ --FILE--
4
+ <?php
5
+ try {
6
+ array_unique ([new stdClass , new stdClass ], SORT_STRING | SORT_FLAG_CASE );
7
+ } catch (Error $ e ) {
8
+ echo $ e ->getMessage ();
9
+ }
10
+ ?>
11
+ --EXPECT--
12
+ Object of class stdClass could not be converted to string
You can’t perform that action at this time.
0 commit comments