# HG changeset patch # User jbe # Date 1406762493 -7200 # Node ID c8c91216255f01d682f30cf22e31759c43d10ad7 # Parent 7b5c13fdc2ec47e0cd877cc042eae17123875372 Correct treatment of top-level null values in JSON parser diff -r 7b5c13fdc2ec -r c8c91216255f libraries/json/json.c --- a/libraries/json/json.c Thu Jul 31 01:02:46 2014 +0200 +++ b/libraries/json/json.c Thu Jul 31 01:21:33 2014 +0200 @@ -381,8 +381,16 @@ } else if (!strncmp(str+pos, "null", 4)) { // consume 4 input characters for "null": pos += 4; - // put special null-marker onto stack: - lua_pushvalue(L, json_import_nullmark_idx); + // different behavor for top-level and sub-levels: + if (level) { + // if sub-level, + // push special null-marker onto stack: + lua_pushvalue(L, json_import_nullmark_idx); + } else { + // if top-level, + // push nil onto stack: + lua_pushnil(L); + } } else { // all other cases are a syntax error: goto json_import_syntax_error;