diff --git a/src/feature/video-logger.c b/src/feature/video-logger.c index ffad97a57..ee773795b 100644 --- a/src/feature/video-logger.c +++ b/src/feature/video-logger.c @@ -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);