File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ PHP NEWS
6060 . Fixed bug GH-19701 (Serialize/deserialize loses some data). (nielsdos)
6161 . Fixed bug GH-19801 (leaks in var_dump() and debug_zval_dump()).
6262 (alexandre-daubois)
63+ . Fixed bug GH-20043 (array_unique assertion failure with RC1 array
64+ causing an exception on sort). (nielsdos)
6365
6466- Streams:
6567 . Fixed bug GH-19248 (Use strerror_r instead of strerror in main).
Original file line number Diff line number Diff line change @@ -5027,6 +5027,11 @@ PHP_FUNCTION(array_unique)
50275027 ZVAL_UNDEF (& arTmp [i ].b .val );
50285028 zend_sort ((void * ) arTmp , i , sizeof (struct bucketindex ),
50295029 (compare_func_t ) cmp , (swap_func_t ) array_bucketindex_swap );
5030+
5031+ if (UNEXPECTED (EG (exception ))) {
5032+ goto out ;
5033+ }
5034+
50305035 /* go through the sorted array and delete duplicates from the copy */
50315036 lastkept = arTmp ;
50325037 for (cmpdata = arTmp + 1 ; Z_TYPE (cmpdata -> b .val ) != IS_UNDEF ; cmpdata ++ ) {
@@ -5046,6 +5051,8 @@ PHP_FUNCTION(array_unique)
50465051 }
50475052 }
50485053 }
5054+
5055+ out :
50495056 pefree (arTmp , GC_FLAGS (Z_ARRVAL_P (array )) & IS_ARRAY_PERSISTENT );
50505057
50515058 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