From e10abcad067b7786cabec0e723c7c61def64b6a1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 13 Sep 2016 10:43:53 +0200 Subject: [PATCH 1/2] - fixed: The TabCommands array needs to be cleared before the NameManager is destroyed. TabCommands use an FName to store the command's name so once the NameManager is destroyed its data will become invalid. This is a problem because C_RemoveTabCommand is being called from FBaseCVar's destructor and most CVARs are global variables. --- src/name.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/name.cpp b/src/name.cpp index 8140829c6..ecedcf0f3 100644 --- a/src/name.cpp +++ b/src/name.cpp @@ -35,6 +35,7 @@ #include #include "name.h" #include "c_dispatch.h" +#include "c_console.h" // MACROS ------------------------------------------------------------------ @@ -268,6 +269,8 @@ FName::NameManager::~NameManager() { NameBlock *block, *next; + C_ClearTabCommands(); + for (block = Blocks; block != NULL; block = next) { next = block->NextBlock; From ba68cfd61153ed260ae1cf3c8dc7e4986ee4fa69 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 13 Sep 2016 21:01:50 +0200 Subject: [PATCH 2/2] - do not even allow creation of names in C_RemoveTabCommands if there are no tab commands, so that FindName cannot be called after the NameManager has been destroyed. --- src/c_console.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/c_console.cpp b/src/c_console.cpp index 086861229..2d164c478 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1747,6 +1747,14 @@ void C_AddTabCommand (const char *name) void C_RemoveTabCommand (const char *name) { + if (TabCommands.Size() == 0) + { + // There are no tab commands that can be removed. + // This is important to skip construction of aname + // in case the NameManager has already been destroyed. + return; + } + FName aname(name, true); if (aname == NAME_None)