From 74f5f080be038bac9ac85440dcbb2cb16fd1dad2 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:34:10 +0300 Subject: [PATCH] Fixed memory leak in strings --- vm/ByteCodeTranslator/src/cn1_globals.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vm/ByteCodeTranslator/src/cn1_globals.m b/vm/ByteCodeTranslator/src/cn1_globals.m index 51ecc12ee9..ae0b3bb143 100644 --- a/vm/ByteCodeTranslator/src/cn1_globals.m +++ b/vm/ByteCodeTranslator/src/cn1_globals.m @@ -528,6 +528,10 @@ void placeObjectInHeapCollection(JAVA_OBJECT obj) { // the thread just died, mark its remaining resources void collectThreadResources(struct ThreadLocalData *current) { + if(threadStateData->utf8Buffer != 0) { + free(threadStateData->utf8Buffer); + threadStateData->utf8Buffer = 0; + } for(int heapTrav = 0 ; heapTrav < current->heapAllocationSize ; heapTrav++) { JAVA_OBJECT obj = (JAVA_OBJECT)current->pendingHeapAllocations[heapTrav]; if(obj) {