Core/Misc: Fix invalid pointer use after being deleted