Skip to content

Commit f6065de

Browse files
committed
Added nil check to table conversion
1 parent e693b89 commit f6065de

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/extractor/scripting_environment_lua.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
259259
"version",
260260
&osmium::Way::version,
261261
"get_nodes",
262-
[](const osmium::Way &way) { return sol::as_table(&way.nodes()); },
262+
[&context](const osmium::Way &way) { return sol::as_table(&way.nodes()); },
263263
"get_location_tag",
264264
[&context, &get_location_tag](const osmium::Way &way, const char *key) {
265265
// HEURISTIC: use a single node (last) of the way to localize the way
@@ -944,6 +944,9 @@ Sol2ScriptingEnvironment::GetStringListFromTable(const std::string &table_name)
944944
auto &context = GetSol2Context();
945945
BOOST_ASSERT(context.state.lua_state() != nullptr);
946946
std::vector<std::string> strings;
947+
if(context.profile_table[table_name] == sol::nil){
948+
return strings;
949+
}
947950
sol::table table = context.profile_table[table_name];
948951
if (table.valid())
949952
{
@@ -962,6 +965,9 @@ Sol2ScriptingEnvironment::GetStringListsFromTable(const std::string &table_name)
962965

963966
auto &context = GetSol2Context();
964967
BOOST_ASSERT(context.state.lua_state() != nullptr);
968+
if(context.profile_table[table_name] == sol::nil){
969+
return string_lists;
970+
}
965971
sol::table table = context.profile_table[table_name];
966972
if (!table.valid())
967973
{

0 commit comments

Comments
 (0)