mirror of
https://github.com/syoyo/tinygltf.git
synced 2026-06-08 03:03:50 +00:00
Address code review feedback: .gitignore path, fuzzer docs, trailing whitespace test
Co-authored-by: syoyo <18676+syoyo@users.noreply.github.com>
This commit is contained in:
@@ -61,7 +61,10 @@ static void fuzz_binary(const uint8_t *data, size_t size) {
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
if (size == 0) return 0;
|
||||
|
||||
/* Use the first byte to select the parse path, pass the rest as input. */
|
||||
/* Use the lowest bit of the first byte to select the parse path.
|
||||
* The remaining bits are left for the fuzzer engine to explore;
|
||||
* additional paths (e.g. LoadASCIIFromFile, check_sections flags)
|
||||
* can be added here in the future using more selector bits. */
|
||||
uint8_t selector = data[0];
|
||||
const uint8_t *payload = data + 1;
|
||||
size_t payload_size = size - 1;
|
||||
|
||||
@@ -401,11 +401,18 @@ TEST_CASE("cj-malformed-incomplete-null", "[customjson][malformed]") {
|
||||
}
|
||||
|
||||
TEST_CASE("cj-malformed-extra-data", "[customjson][malformed]") {
|
||||
// Valid JSON followed by extra data
|
||||
// Valid JSON followed by extra non-whitespace data
|
||||
auto doc = JsonConstruct("42 extra");
|
||||
REQUIRE(doc.is_null());
|
||||
}
|
||||
|
||||
TEST_CASE("cj-trailing-whitespace-ok", "[customjson][parse]") {
|
||||
// Valid JSON followed by whitespace only should be accepted
|
||||
auto doc = JsonConstruct("42 \t\n ");
|
||||
REQUIRE(doc.is_number());
|
||||
REQUIRE(doc.get<int>() == 42);
|
||||
}
|
||||
|
||||
TEST_CASE("cj-malformed-just-brace", "[customjson][malformed]") {
|
||||
auto doc = JsonConstruct("{");
|
||||
REQUIRE(doc.is_null());
|
||||
|
||||
Reference in New Issue
Block a user