master: fix use after free