Commit 5f64dc55 authored by Damien George's avatar Damien George
Browse files

extmod: Make ujson.loads raise exception if given empty string.

Addresses issue #1097.
parent e8b877be
......@@ -239,7 +239,8 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
// unexpected chars
goto fail;
}
if (stack.len != 0) {
if (stack_top == MP_OBJ_NULL || stack.len != 0) {
// not exactly 1 object
goto fail;
}
vstr_clear(&vstr);
......
......@@ -33,3 +33,9 @@ my_print(json.loads('{"a":[], "b":[1], "c":{"3":4}}'))
# whitespace handling
my_print(json.loads('{\n\t"a":[]\r\n, "b":[1], "c":{"3":4} \n\r\t\r\r\r\n}'))
# loading nothing should raise exception
try:
json.loads('')
except ValueError:
print('ValueError')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment