WebPMuxGetChunk: add an assert

assert idx != IDX_LAST_CHUNK to quiet a static analysis warning
(reported by Coverity):
  overrun-local: Overrunning array kChunks of 11 12-byte elements at
    element index 11 (byte offset 143) using index idx (which evaluates
    to 11).

Change-Id: I85ae159e338d5670c007f76277ffe94e7a1dcafc
This commit is contained in:
James Zern 2024-03-21 18:26:15 -07:00
parent 955a3d14ae
commit 3c0011bbd1

View File

@ -432,6 +432,7 @@ WebPMuxError WebPMuxGetChunk(const WebPMux* mux, const char fourcc[4],
return WEBP_MUX_INVALID_ARGUMENT; return WEBP_MUX_INVALID_ARGUMENT;
} }
idx = ChunkGetIndexFromFourCC(fourcc); idx = ChunkGetIndexFromFourCC(fourcc);
assert(idx != IDX_LAST_CHUNK);
if (IsWPI(kChunks[idx].id)) { // An image chunk. if (IsWPI(kChunks[idx].id)) { // An image chunk.
return WEBP_MUX_INVALID_ARGUMENT; return WEBP_MUX_INVALID_ARGUMENT;
} else if (idx != IDX_UNKNOWN) { // A known chunk type. } else if (idx != IDX_UNKNOWN) { // A known chunk type.