From e1ba26dafecb85a73a0856ff001594acb25c4db4 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Thu, 2 Jun 2011 05:36:15 +0500 Subject: util.json: Fixed handling of truncated JSON. --- util/json.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'util') diff --git a/util/json.lua b/util/json.lua index 05453703..cfa84a4b 100644 --- a/util/json.lua +++ b/util/json.lua @@ -134,12 +134,14 @@ end 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; -- cgit v1.2.3