summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-04-01 10:33:05 +0200
committerJo-Philipp Wich <jo@mein.io>2021-04-01 10:33:05 +0200
commit7f0ff9143159cfa76408ed3dfedb2d730b17fb46 (patch)
tree065cd84e7088e63f1006505b19d6e28bb516218a
parent973cc6c865dcf6075c493125313058b650b08234 (diff)
lib: allow parsing non-array, non-object value in json()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--lib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 23141a3..ea48e34 100644
--- a/lib.c
+++ b/lib.c
@@ -2053,7 +2053,10 @@ uc_json(uc_vm *vm, size_t nargs)
str = json_object_get_string(src);
len = json_object_get_string_len(src);
- rv = json_tokener_parse_ex(tok, str, len);
+ /* NB: the len + 1 here is intentional to pass the terminating \0 byte
+ * to the json-c parser. This is required to work-around upstream
+ * issue #681 <https://github.com/json-c/json-c/issues/681> */
+ rv = json_tokener_parse_ex(tok, str, len + 1);
err = json_tokener_get_error(tok);
if (err == json_tokener_continue) {