Fix use after free (pr16103).