mirror of https://github.com/mgba-emu/mgba.git
Core: Fix memory leak when reloading mVL header
This commit is contained in:
parent
8e79530cc6
commit
909886d2e1
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue