Fix another use after free
Coverity CID 1034471
(cherry picked from commit 469748a139d2879fa65e2e35b649d60136be0e6d)