/src/tinyobjloader/fuzzer/fuzz_ParseFromString.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include <stdio.h> |
2 | | #include <stdlib.h> |
3 | | #include <stdint.h> |
4 | | #include <stdarg.h> |
5 | | #include <string.h> |
6 | | |
7 | | #define TINYOBJLOADER_IMPLEMENTATION // define this in only *one* .cc |
8 | | #include "tiny_obj_loader.h" |
9 | | |
10 | 82 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
11 | 82 | tinyobj::ObjReaderConfig reader_config; |
12 | 82 | tinyobj::ObjReader reader; |
13 | 82 | if (Size < 2) { |
14 | 0 | return 0; |
15 | 0 | } |
16 | 27.7M | for (size_t i = 0; i < Size-1; i++) { |
17 | 27.7M | if (Data[i] == 0) { |
18 | 82 | std::string obj_text (reinterpret_cast<const char*>(Data), i); |
19 | 82 | std::string mtl_text (reinterpret_cast<const char*>(Data+i+1), Size-i-1); |
20 | 82 | reader.ParseFromString(obj_text, mtl_text,reader_config); |
21 | 82 | return 0; |
22 | 82 | } |
23 | 27.7M | } |
24 | 0 | return 0; |
25 | 82 | } |
26 | | |