muxread,MuxImageParse: add missing error checks

This prevents leaks should an allocation fail.

Spotted by Philippe Antoine (p dot antoine at catenacyber dot fr)
and https://github.com/catenacyber/nallocfuzz.

Change-Id: I07a8a475a282b18bf2f9015cc5b1120772babd48
This commit is contained in:
James Zern 2023-06-14 13:50:57 -07:00
parent ebb6f949f4
commit 2e5a9ec3b6

View File

@ -116,9 +116,12 @@ static int MuxImageParse(const WebPChunk* const chunk, int copy_data,
// Each of ANMF chunk contain a header at the beginning. So, its size should
// be at least 'hdr_size'.
if (size < hdr_size) goto Fail;
ChunkAssignData(&subchunk, &temp, copy_data, chunk->tag_);
if (ChunkAssignData(&subchunk, &temp, copy_data,
chunk->tag_) != WEBP_MUX_OK) {
goto Fail;
}
ChunkSetHead(&subchunk, &wpi->header_);
}
if (ChunkSetHead(&subchunk, &wpi->header_) != WEBP_MUX_OK) goto Fail;
wpi->is_partial_ = 1; // Waiting for ALPH and/or VP8/VP8L chunks.
// Rest of the chunks.