Fixes coverity issue CID 1063352, use after free bug