Skip to content

Commit 52e31eb

Browse files
committed
[[ Bug 22009 ]] Fix memory leak when releasing LCB objects
This patch fixes memory leaks which can occur when releasing loaded LCB modules and module instances. The leaks occur due to a failure to free the base record of the objects and a failure to release some parts of the loaded compiled module structure.
1 parent b5e0e6b commit 52e31eb

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

docs/notes/bugfix-22009.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix memory leaks when releasing loaded LCB modules and instances

libfoundation/src/foundation-pickle.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,8 @@ static void MCPickleReleaseField(MCPickleFieldType p_kind, void *p_base_ptr, voi
978978
MCPickleRelease(t_info -> cases[t_case] . record, t_variant);
979979
break;
980980
}
981+
982+
free(t_variant);
981983
}
982984
}
983985
free(*(void **)p_field_ptr);

libscript/src/script-object.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ void MCScriptDestroyObject(MCScriptObject *self)
253253
__MCScriptAssert__(false, "invalid kind");
254254
break;
255255
}
256+
257+
MCMemoryDeallocate(self);
256258
}
257259

258260
MCScriptObject *MCScriptRetainObject(MCScriptObject *self)

0 commit comments

Comments
 (0)