diff options
author | Waqas Hussain <waqas20@gmail.com> | 2011-06-02 05:36:15 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2011-06-02 05:36:15 +0500 |
commit | e1ba26dafecb85a73a0856ff001594acb25c4db4 (patch) | |
tree | e069a72bf41c37453f81144696ad194e7d016368 | |
parent | 0ffdcd1dd76f1fb6e8e9d2cc3540e5b472dc6e60 (diff) | |
download | prosody-e1ba26dafecb85a73a0856ff001594acb25c4db4.tar.gz prosody-e1ba26dafecb85a73a0856ff001594acb25c4db4.zip |
util.json: Fixed handling of truncated JSON.
-rw-r--r-- | util/json.lua | 2 |
1 files changed, 2 insertions, 0 deletions
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; |