Fix use after free