Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion extmod/modjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ static mp_obj_t mod_json_load(mp_obj_t stream_obj) {
for (;;) {
cont:
if (S_END(s)) {
break;
// Input finished abruptly in the middle of a composite entity.
goto fail;
}
mp_obj_t next = MP_OBJ_NULL;
bool enter = false;
Expand Down
24 changes: 24 additions & 0 deletions tests/extmod/json_loads.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,27 @@ def my_print(o):
my_print(json.loads("[null] a"))
except ValueError:
print("ValueError")

# incomplete object declaration
try:
my_print(json.loads('{"a":0,'))
except ValueError:
print("ValueError")

# incomplete nested array declaration
try:
my_print(json.loads('{"a":0, ['))
except ValueError:
print("ValueError")

# incomplete array declaration
try:
my_print(json.loads('[0,'))
except ValueError:
print("ValueError")

# incomplete nested object declaration
try:
my_print(json.loads('[0, {"a":0, '))
except ValueError:
print("ValueError")
Loading