From 321d948f8d73f0267293ea54c2da4f4262678856 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 3 Feb 2020 20:21:10 -0600 Subject: [PATCH] Fix crash on missing symbols. Fixes #1487. --- library/LuaTools.cpp | 4 ++++ library/include/MemAccess.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/library/LuaTools.cpp b/library/LuaTools.cpp index 3ac52bf45..0b6065940 100644 --- a/library/LuaTools.cpp +++ b/library/LuaTools.cpp @@ -1922,6 +1922,10 @@ static void Lua::Core::InitCoreContext() void DFHack::Lua::Core::Reset(color_ostream &out, const char *where) { + // This can happen if DFHack fails to initialize. + if (!State) + return; + int top = lua_gettop(State); if (top != 0) diff --git a/library/include/MemAccess.h b/library/include/MemAccess.h index 7f3be74df..af1e250d2 100644 --- a/library/include/MemAccess.h +++ b/library/include/MemAccess.h @@ -254,7 +254,8 @@ namespace DFHack }; void ValidateDescriptionOS() { - my_descriptor->ValidateOS(); + if (my_descriptor) + my_descriptor->ValidateOS(); }; uintptr_t getBase();