MemArena: Fix a memory leak caused by pointer confusion

This code was ported from out_ptr, which was a double-pointer, and
wanted to double-check that the proper arena was actually allocated.

When I ported it to store the pointer directly in the view regardless
of whether out_ptr was non-NULL, I got confused here and instead
caused the code to only free the arena if the first byte was non-zero.
This commit is contained in:
Jasper St. Pierre 2014-11-02 17:32:22 -08:00
parent 204598a082
commit 64540bc60d
1 changed files with 1 additions and 1 deletions

View File

@ -267,7 +267,7 @@ void MemoryMap_Shutdown(MemoryView *views, int num_views, u32 flags, MemArena *a
for (int i = 0; i < num_views; i++)
{
MemoryView* view = &views[i];
if (view->mapped_ptr && *(u8*)view->mapped_ptr && !freeset.count(view->mapped_ptr))
if (view->mapped_ptr && !freeset.count(view->mapped_ptr))
{
arena->ReleaseView(view->mapped_ptr, view->size);
freeset.insert(view->mapped_ptr);