Fix a possible use-after-free.