From 11090febb1c7a8a887f6ad14f122d43b0654024f Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Thu, 2 Jun 2011 05:36:15 +0500 Subject: [PATCH] util.json: Fixed handling of truncated JSON. --- util/json.lua | 2 ++ 1 file changed, 2 insertions(+) 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; -- 2.30.2