all repos — mgba @ 909886d2e14f3ca429958fb2cf78edf7980044dd

mGBA Game Boy Advance Emulator

Core: Fix memory leak when reloading mVL header
Vicki Pfau vi@endrift.com
Mon, 24 Apr 2017 14:00:59 -0700
commit

909886d2e14f3ca429958fb2cf78edf7980044dd

parent

8e79530cc60712b0c0c6f74d1f6a50b0e81ad167

1 files changed, 7 insertions(+), 0 deletions(-)

jump to
M src/feature/video-logger.csrc/feature/video-logger.c

@@ -458,6 +458,8 @@ struct mVideoLogContext* context = malloc(sizeof(*context));

memset(context, 0, sizeof(*context)); context->write = !!core; + context->initialStateSize = 0; + context->initialState = NULL; if (core) { context->initialStateSize = core->stateSize(core);

@@ -555,6 +557,11 @@ return false;

} if (header.blockType != mVL_BLOCK_INITIAL_STATE) { return false; + } + if (context->initialState) { + mappedMemoryFree(context->initialState, context->initialStateSize); + context->initialState = NULL; + context->initialStateSize = 0; } if (header.flags & mVL_FLAG_BLOCK_COMPRESSED) { #ifdef USE_ZLIB