From 68bd7265f8dc7850fd1750275b355d828031d6f0 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Tue, 16 Nov 2021 03:28:40 +0700 Subject: [PATCH] Fix database creating/loading methods Methods didn't do `none` checks where necessary and passed `MutableText` as a key, where `Text` keys were expected. --- sources/Data/Database/DBAPI.uc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sources/Data/Database/DBAPI.uc b/sources/Data/Database/DBAPI.uc index 71923e1..3f2ddd3 100644 --- a/sources/Data/Database/DBAPI.uc +++ b/sources/Data/Database/DBAPI.uc @@ -51,6 +51,7 @@ public final function Database Load(Text databaseLink) { local Parser parser; local Database result; + local Text immutableDatabaseName; local MutableText databaseName; if (databaseLink == none) { return none; @@ -65,9 +66,11 @@ public final function Database Load(Text databaseLink) parser.FreeSelf(); return none; } - result = LoadLocal(databaseName); + immutableDatabaseName = databaseName.Copy(); + result = LoadLocal(immutableDatabaseName); parser.FreeSelf(); databaseName.FreeSelf(); + immutableDatabaseName.FreeSelf(); return result; } @@ -156,6 +159,9 @@ public final function LocalDatabaseInstance LoadLocal(Text databaseName) local Text rootRecordName; local LocalDatabase newConfig; local LocalDatabaseInstance newLocalDBInstance; + if (databaseName == none) { + return none; + } CreateLocalDBMapIfMissing(); if (loadedLocalDatabases.HasKey(databaseName)) { @@ -214,6 +220,9 @@ public final function bool DeleteLocal(Text databaseName) local LocalDatabase localDatabaseConfig; local LocalDatabaseInstance localDatabase; local AssociativeArray.Entry dbEntry; + if (databaseName == none) { + return false; + } CreateLocalDBMapIfMissing(); // To delete database we first need to load it localDatabase = LoadLocal(databaseName);