Core: Fix memory leak when reloading mVL header

This commit is contained in:
Vicki Pfau 2017-04-24 14:00:59 -07:00
parent 8e79530cc6
commit 909886d2e1
1 changed files with 7 additions and 0 deletions

View File

@ -458,6 +458,8 @@ struct mVideoLogContext* mVideoLogContextCreate(struct mCore* core) {
memset(context, 0, sizeof(*context));
context->write = !!core;
context->initialStateSize = 0;
context->initialState = NULL;
if (core) {
context->initialStateSize = core->stateSize(core);
@ -556,6 +558,11 @@ bool _readHeader(struct mVideoLogContext* context) {
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
struct VFile* vfm = VFileMemChunk(NULL, 0);