diff --git a/src/load.c b/src/load.c index 2c7b71e..894ee10 100644 --- a/src/load.c +++ b/src/load.c @@ -699,7 +699,7 @@ static json_t *parse_object(lex_t *lex, size_t flags, json_error_t *error) key = lex_steal_string(lex, &len); if(!key) return NULL; - if (memchr(key, len, '\0')) { + if (memchr(key, '\0', len)) { jsonp_free(key); error_set(error, lex, "NUL byte in object key not supported"); goto error; diff --git a/test/suites/invalid/null-byte-in-object-key/error b/test/suites/invalid/null-byte-in-object-key/error new file mode 100644 index 0000000..3ec685b --- /dev/null +++ b/test/suites/invalid/null-byte-in-object-key/error @@ -0,0 +1,2 @@ +1 15 15 +NUL byte in object key not supported near '"foo\u0000bar"' diff --git a/test/suites/invalid/null-byte-in-object-key/input b/test/suites/invalid/null-byte-in-object-key/input new file mode 100644 index 0000000..593f0f6 --- /dev/null +++ b/test/suites/invalid/null-byte-in-object-key/input @@ -0,0 +1 @@ +{"foo\u0000bar": 42} \ No newline at end of file