From 0b9b883b791b2808bc51a42bee9de08e9a1f0f64 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Fri, 21 Dec 2018 15:42:50 -0800 Subject: [PATCH] libpng-proto: don't use vector, use a plain array instead --- projects/libpng-proto/png_proto_fuzzer_example.cc | 7 ++++--- 1 file 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 #include #include -#include #include // 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 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();