diff options
author | Kostya Serebryany <kcc@google.com> | 2018-12-21 15:42:50 -0800 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2018-12-21 15:42:50 -0800 |
commit | 0b9b883b791b2808bc51a42bee9de08e9a1f0f64 (patch) | |
tree | d9e07667266642932aa006d2fb9a182c063bd2eb /projects/libpng-proto | |
parent | e47326293df7aa634d49760ebd0ad9871c9996a0 (diff) | |
download | oss-fuzz-0b9b883b791b2808bc51a42bee9de08e9a1f0f64.tar.gz |
libpng-proto: don't use vector, use a plain array instead
Diffstat (limited to 'projects/libpng-proto')
-rw-r--r-- | projects/libpng-proto/png_proto_fuzzer_example.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/projects/libpng-proto/png_proto_fuzzer_example.cc b/projects/libpng-proto/png_proto_fuzzer_example.cc index 346f12f33..7f235d6b0 100644 --- a/projects/libpng-proto/png_proto_fuzzer_example.cc +++ b/projects/libpng-proto/png_proto_fuzzer_example.cc @@ -2,7 +2,6 @@ #include <string> #include <sstream> #include <fstream> -#include <vector> #include <zlib.h> // for crc32 #include "libprotobuf-mutator/src/libfuzzer/libfuzzer_macro.h" @@ -60,12 +59,14 @@ std::string ProtoToPng(const PngProto &png_proto) { auto &other_chunk = chunk.other_chunk(); char type[5] = {0}; if (other_chunk.has_known_type()) { - static const std::vector<const char *> known_chunks = { + static const char * known_chunks[] = { "bKGD", "cHRM", "dSIG", "eXIf", "gAMA", "hIST", "iCCP", "iTXt", "pHYs", "sBIT", "sPLT", "sRGB", "sTER", "tEXt", "tIME", "tRNS", "zTXt", "sCAL", "pCAL", "oFFs", }; - size_t chunk_idx = other_chunk.known_type() % known_chunks.size(); + size_t known_chunks_size = + sizeof(known_chunks) / sizeof(known_chunks[0]); + size_t chunk_idx = other_chunk.known_type() % known_chunks_size; memcpy(type, known_chunks[chunk_idx], 4); } else if (other_chunk.has_unknown_type()) { uint32_t unknown_type_int = other_chunk.unknown_type(); |