Merge "fix potential use-after-frees of stack memory"