Which is use after free since commit 278437b266ed97cebb8e1c14be6cfa2c4f440f07.
Thanks Bernhard Übelacker for spotting this (based on ASan validation). For a general case I'd say we can have some tests intentionally doing use after free but it is not needed here.