lua: json: catch syntax errors when converting to native lua types

and most importantly, push nil on the stack, so that there is something
returned from this function... the caller always expects a value to
be pushed
This commit is contained in:
George Kiagiadakis
2023-05-25 18:22:26 +03:00
parent 8912dc25c3
commit 70980fe355

View File

@@ -165,6 +165,13 @@ push_luajson (lua_State *L, WpSpaJson *json)
lua_setfield (L, -2, key_str);
}
}
/* syntax error */
else {
g_autofree gchar *value = wp_spa_json_parse_string (json);
wp_warning ("unknown SPA JSON token type at '%s'", value);
lua_pushnil (L);
}
}
static int