fix use-after-free.