From 816bf3968d83f67a3deda1e539173e8627b40d98 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 6 Mar 2023 02:53:19 +0700 Subject: [PATCH] Fix memory leak in `DBAPI`'s `LoadLocal()` --- sources/Data/Database/DBAPI.uc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/Data/Database/DBAPI.uc b/sources/Data/Database/DBAPI.uc index 1ca767e..46f38b0 100644 --- a/sources/Data/Database/DBAPI.uc +++ b/sources/Data/Database/DBAPI.uc @@ -166,6 +166,7 @@ public final function LocalDatabaseInstance LoadLocal(BaseText databaseName) local Text rootRecordName; local LocalDatabase newConfig; local LocalDatabaseInstance newLocalDBInstance; + local Text dbKey; if (databaseName == none) { return none; @@ -186,7 +187,9 @@ public final function LocalDatabaseInstance LoadLocal(BaseText databaseName) return none; } newLocalDBInstance = LocalDatabaseInstance(_.memory.Allocate(localDBClass)); - loadedLocalDatabases.SetItem(databaseName.Copy(), newLocalDBInstance); + dbKey = databaseName.Copy(); + loadedLocalDatabases.SetItem(dbKey, newLocalDBInstance); + dbKey.FreeSelf(); if (newConfig.HasDefinedRoot()) { rootRecordName = newConfig.GetRootName();