schemagen: handle WeaselJsonParser_create failure in RootBuilder #46

Merged
andrew merged 1 commits from weaselbot/weaseljson:weaselbot/issue-36 into main 2026-06-30 15:35:21 +00:00
Member

Closes #36

If WeaselJsonParser_create returns nullptr (e.g. negative stack size or allocation failure), set the existing error_ flag so that subsequent feed()/finish() calls return WeaselJson_REJECT instead of dereferencing the null parser_.

Also adds a regression test in contrib/schemagen/test_gen.cpp that constructs a RootBuilder with an invalid stack size and verifies it rejects without crashing.

Closes #36 If `WeaselJsonParser_create` returns `nullptr` (e.g. negative stack size or allocation failure), set the existing `error_` flag so that subsequent `feed()`/`finish()` calls return `WeaselJson_REJECT` instead of dereferencing the null parser_. Also adds a regression test in `contrib/schemagen/test_gen.cpp` that constructs a `RootBuilder` with an invalid stack size and verifies it rejects without crashing.
weaselbot added 1 commit 2026-06-30 15:27:10 +00:00
schemagen: handle WeaselJsonParser_create failure in RootBuilder
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (pull_request) Successful in 51s
CI / pre-commit (pull_request) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (pull_request) Successful in 51s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (pull_request) Successful in 1m34s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (pull_request) Successful in 1m27s
abeaae7ed7
If WeaselJsonParser_create returns nullptr (e.g. negative stack size or allocation failure), set the existing error_ flag so that subsequent feed()/finish() calls return WeaselJson_REJECT instead of dereferencing the null parser_.

Also add a regression test in test_gen.cpp that constructs a RootBuilder with an invalid stack size and verifies it rejects without crashing.

Closes #36
andrew merged commit 241c29073b into main 2026-06-30 15:35:21 +00:00
andrew deleted branch weaselbot/issue-36 2026-06-30 15:35:21 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weaselab/weaseljson#46