From 6520039dc2055da5a4ede4c582a58fab6c8bd53c Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Wed, 15 Jul 2026 14:12:41 -0400 Subject: [PATCH] Address review feedback --- include/weaseljson.h | 2 +- src/test.cpp | 3 +-- src/validate.cpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/weaseljson.h b/include/weaseljson.h index 211dd1b..aa0ec52 100644 --- a/include/weaseljson.h +++ b/include/weaseljson.h @@ -67,7 +67,7 @@ void WeaselJsonParser_destroy(WeaselJsonParser *parser); /** Incrementally parse `len` more bytes starting at `buf`. `buf` may be * modified. Call with `len` 0 to indicate end of data. `buf` may be null if * `len` is 0. `len` must not be negative; a negative length is treated as a - * rejected input. */ + * rejected input. Returns WeaselJson_NULL if parser is null */ WeaselJsonStatus WeaselJsonParser_parse(WeaselJsonParser *parser, char *buf, int len); diff --git a/src/test.cpp b/src/test.cpp index 0c63161..10cb1fb 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -331,8 +331,7 @@ TEST_CASE("parse rejects negative length") { } TEST_CASE("Calling parse with nullptr doesn't crash") { - char buf[10] = "hello"; - REQUIRE(WeaselJsonParser_parse(nullptr, buf, -1) == WeaselJson_NULL); + REQUIRE(WeaselJsonParser_parse(nullptr, nullptr, 0) == WeaselJson_NULL); } TEST_CASE("streaming") { testStreaming(json); } diff --git a/src/validate.cpp b/src/validate.cpp index f8d1adc..9566056 100644 --- a/src/validate.cpp +++ b/src/validate.cpp @@ -34,7 +34,7 @@ int main(int argc, char **argv) { case WeaselJson_OVERFLOW: return 1; case WeaselJson_NULL: - fprintf(stderr, "Could not create parser\n"); + fprintf(stderr, "parse called with a null parser\n"); return 1; } if (l == 0) {