From 88f87bc4acd4214b33ec79aa71f2b8aab8a2120c Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 22 Sep 2009 12:31:45 +0000 Subject: [PATCH] (svn r17610) [0.7] -Fix [FS#3227] (r17302): reloading an AI caused reading and later freeing of already freed memory --- src/company_cmd.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index e67df3bec0..a1d8142ac9 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -59,7 +59,14 @@ Company::~Company() if (CleaningPool()) return; DeleteCompanyWindows(this->index); - this->name_1 = 0; + + /* Zero the memory of the company; we might 'reuse' it later on. + * This is more a hack than a proper fix, but... it's already + * fixed in trunk by the new pool system and this is the only + * troublesome case in 0.7, so we'll leave it at this fix. */ + CompanyID id = this->index; + memset(this, 0, sizeof(*this)); + this->index = id; } /**