# HG changeset patch # User Waqas Hussain # Date 1306974975 -18000 # Node ID 20979f124ad90d5b84ac56d7851d8845d7bf289c # Parent f5a46b73432bd0019637c322f797cca381f27666 util.json: Fixed handling of truncated JSON. diff -r f5a46b73432b -r 20979f124ad9 util/json.lua --- a/util/json.lua Thu Jun 02 00:26:23 2011 +0100 +++ b/util/json.lua Thu Jun 02 05:36:15 2011 +0500 @@ -134,12 +134,14 @@ function json.decode(json) + json = json.." "; -- appending a space ensures valid json wouldn't touch EOF local pos = 1; local current = {}; local stack = {}; local ch, peek; local function next() ch = json:sub(pos, pos); + if ch == "" then error("Unexpected EOF"); end pos = pos+1; peek = json:sub(pos, pos); return ch;