1--TEST-- 2GH-16648: Use-after-free during array sorting 3--FILE-- 4<?php 5 6function resize_arr() { 7 global $arr; 8 for ($i = 0; $i < 10; $i++) { 9 $arr[$i] = $i; 10 } 11} 12 13class C { 14 function __toString() { 15 resize_arr(); 16 return '3'; 17 } 18} 19 20$arr = ['a' => '1', '3' => new C, '2' => '2']; 21asort($arr); 22var_dump($arr); 23 24?> 25--EXPECT-- 26array(11) { 27 ["a"]=> 28 string(1) "1" 29 [3]=> 30 int(3) 31 [2]=> 32 int(2) 33 [0]=> 34 int(0) 35 [1]=> 36 int(1) 37 [4]=> 38 int(4) 39 [5]=> 40 int(5) 41 [6]=> 42 int(6) 43 [7]=> 44 int(7) 45 [8]=> 46 int(8) 47 [9]=> 48 int(9) 49} 50