Skip to content

Commit ff4a8a8

Browse files
committed
Fix for #43:
gom Lua interop was causing crash when expecting an OGF::Object* from a Lua function and getting a NULL pointer. The warning message was trying to display the result of lua_tostring() (by sending it to a sstream), which crashes under Windows. This was triggered by the mechanism that memorizes the latest picked object, that is written in half-C++ / half-Lua (and sometimes, of course, there is no picked object, hence a NULL pointer)
1 parent f5056fa commit ff4a8a8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/lib/OGF/gom/lua/interop.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,13 @@ namespace OGF {
175175
result.set_value(lua_callable);
176176
return;
177177
} else {
178-
Logger::warn("GOMLua")
179-
<< "Expected Object, got "
180-
<< lua_tostring(L,index) << " instead"
181-
<< std::endl;
178+
const char* s = lua_tostring(L,index);
179+
if(s != nullptr) {
180+
Logger::warn("GOMLua")
181+
<< "Expected Object, got "
182+
<< (s ? s : "NULL") << " instead"
183+
<< std::endl;
184+
}
182185
result.reset();
183186
return;
184187
}

0 commit comments

Comments
 (0)