From 276098f9dbd2d78b6e1d6783a2582bddf0b5e13b Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 17 Sep 2018 23:03:05 -0400 Subject: [PATCH] fix crash when using elem.element on windows --- src/lua/LuaScriptInterface.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index 5f4e3a175..796072197 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -2399,11 +2399,17 @@ void LuaScriptInterface::LuaGetProperty(lua_State* l, StructProperty property, i lua_pushinteger(l, *((unsigned char*)propertyAddress)); break; case StructProperty::BString: - lua_pushstring(l, *((char**)propertyAddress)); + { + ByteString byteStringProperty = *((ByteString*)propertyAddress); + lua_pushstring(l, byteStringProperty.c_str()); break; + } case StructProperty::String: - lua_pushstring(l, (*((String*)propertyAddress)).ToUtf8().c_str()); + { + ByteString byteStringProperty = (*((String*)propertyAddress)).ToUtf8(); + lua_pushstring(l, byteStringProperty.c_str()); break; + } case StructProperty::Colour: #if PIXELSIZE == 4 lua_pushinteger(l, *((unsigned int*)propertyAddress));