1--TEST-- 2GH-16337 (Use-after-free in SplHeap) 3--FILE-- 4<?php 5 6class C { 7 function __toString() { 8 global $heap; 9 try { 10 $heap->extract(); 11 } catch (Throwable $e) { 12 echo $e->getMessage(), "\n"; 13 } 14 try { 15 $heap->insert(1); 16 } catch (Throwable $e) { 17 echo $e->getMessage(), "\n"; 18 } 19 echo $heap->top(), "\n"; 20 return "0"; 21 } 22} 23 24$heap = new SplMinHeap; 25for ($i = 0; $i < 100; $i++) { 26 $heap->insert((string) $i); 27} 28$heap->insert(new C); 29 30?> 31--EXPECT-- 32Heap cannot be changed when it is already being modified. 33Heap cannot be changed when it is already being modified. 340 35Heap cannot be changed when it is already being modified. 36Heap cannot be changed when it is already being modified. 370 38Heap cannot be changed when it is already being modified. 39Heap cannot be changed when it is already being modified. 400 41Heap cannot be changed when it is already being modified. 42Heap cannot be changed when it is already being modified. 430 44Heap cannot be changed when it is already being modified. 45Heap cannot be changed when it is already being modified. 460 47Heap cannot be changed when it is already being modified. 48Heap cannot be changed when it is already being modified. 490 50