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)
50445044 ZVAL_UNDEF (& arTmp [i ].b .val );
50455045 zend_sort ((void * ) arTmp , i , sizeof (struct bucketindex ),
50465046 (compare_func_t ) cmp , (swap_func_t ) array_bucketindex_swap );
5047+
5048+ if (UNEXPECTED (EG (exception ))) {
5049+ goto out ;
5050+ }
5051+
50475052 /* go through the sorted array and delete duplicates from the copy */
50485053 lastkept = arTmp ;
50495054 for (cmpdata = arTmp + 1 ; Z_TYPE (cmpdata -> b .val ) != IS_UNDEF ; cmpdata ++ ) {
@@ -5063,6 +5068,8 @@ PHP_FUNCTION(array_unique)
50635068 }
50645069 }
50655070 }
5071+
5072+ out :
50665073 pefree (arTmp , GC_FLAGS (Z_ARRVAL_P (array )) & IS_ARRAY_PERSISTENT );
50675074
50685075 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