luci-lib-jsonc: Ignore non-string-or-number keys in tables
Previously, the following caused a segmentation fault: json.stringify({[{}] = true}) This was caused by lua_tostring() returning NULL for anything but strings and numbers, letting json_object_object_add crash. This patch makes jsonc ignore all keys which have no string representation altogether. Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
This commit is contained in:
parent
0d5070c510
commit
e32a877aa4
1 changed files with 3 additions and 2 deletions
|
@ -286,6 +286,7 @@ static struct json_object * _lua_to_json(lua_State *L, int index)
|
||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
key = lua_tostring(L, -1);
|
key = lua_tostring(L, -1);
|
||||||
|
|
||||||
|
if (key)
|
||||||
json_object_object_add(obj, key,
|
json_object_object_add(obj, key,
|
||||||
_lua_to_json(L, lua_gettop(L) - 1));
|
_lua_to_json(L, lua_gettop(L) - 1));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue