summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2009-01-17 14:54:24 +0000
committertruebrain <truebrain@openttd.org>2009-01-17 14:54:24 +0000
commit8cbf156252a712b4ce05db9b464355b4cfd5fe5f (patch)
treed6b79724651cef87fc2edd5fc068f6100c053697 /src/ai
parent3980e2739a6d5bf108594a02d92f102df30a0dc1 (diff)
downloadopenttd-8cbf156252a712b4ce05db9b464355b4cfd5fe5f.tar.xz
(svn r15120) -Fix: more mem-leak fixes
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_info.cpp5
-rw-r--r--src/ai/ai_scanner.cpp10
2 files changed, 12 insertions, 3 deletions
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp
index 9528f32cd..60503f7dd 100644
--- a/src/ai/ai_info.cpp
+++ b/src/ai/ai_info.cpp
@@ -359,7 +359,10 @@ int AIInfo::GetSettingDefaultValue(const char *name)
AILibrary *library = new AILibrary();
SQInteger res = AIFileInfo::Constructor(vm, library, true);
- if (res != 0) return res;
+ if (res != 0) {
+ delete library;
+ return res;
+ }
/* Register the Library to the base system */
library->base->RegisterLibrary(library);
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp
index 3c74cdb92..d7fc258c7 100644
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -277,7 +277,10 @@ void AIScanner::RegisterLibrary(AILibrary *library)
if (this->library_list.find(library_name) != this->library_list.end()) {
/* This AI was already registered */
- if (strcmp(this->library_list[library_name]->GetMainScript(), library->GetMainScript()) == 0) return;
+ if (strcmp(this->library_list[library_name]->GetMainScript(), library->GetMainScript()) == 0) {
+ delete library;
+ return;
+ }
DEBUG(ai, 0, "Registering two libraries with the same name and version");
DEBUG(ai, 0, " 1: %s", this->library_list[library_name]->GetMainScript());
@@ -306,7 +309,10 @@ void AIScanner::RegisterAI(AIInfo *info)
if (this->info_list.find(ai_name) != this->info_list.end()) {
/* This AI was already registered */
- if (strcmp(this->info_list[ai_name]->GetMainScript(), info->GetMainScript()) == 0) return;
+ if (strcmp(this->info_list[ai_name]->GetMainScript(), info->GetMainScript()) == 0) {
+ delete info;
+ return;
+ }
DEBUG(ai, 0, "Registering two AIs with the same name and version");
DEBUG(ai, 0, " 1: %s", this->info_list[ai_name]->GetMainScript());