mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
Fix a memleak in WebPMuxCreate()
Change-Id: I3658b5ae487082aef28989eb8abc274c207fef0f
This commit is contained in:
parent
4c3975792b
commit
777341c3d0
@ -85,6 +85,8 @@ WebPMux* WebPMuxCreateInternal(const WebPData* const bitstream, int copy_data,
|
||||
WebPMuxImage* wpi = NULL;
|
||||
const uint8_t* data;
|
||||
size_t size;
|
||||
WebPChunk chunk;
|
||||
ChunkInit(&chunk);
|
||||
|
||||
// Sanity checks.
|
||||
if (version != WEBP_MUX_ABI_VERSION) goto Err; // version mismatch
|
||||
@ -132,10 +134,8 @@ WebPMux* WebPMuxCreateInternal(const WebPData* const bitstream, int copy_data,
|
||||
// Loop over chunks.
|
||||
while (data != end) {
|
||||
WebPChunkId id;
|
||||
WebPChunk chunk;
|
||||
WebPMuxError err;
|
||||
|
||||
ChunkInit(&chunk);
|
||||
err = ChunkAssignData(&chunk, data, size, riff_size, copy_data);
|
||||
if (err != WEBP_MUX_OK) goto Err;
|
||||
|
||||
@ -164,12 +164,12 @@ WebPMux* WebPMuxCreateInternal(const WebPData* const bitstream, int copy_data,
|
||||
if (chunk_list == NULL) chunk_list = &mux->unknown_;
|
||||
if (ChunkSetNth(&chunk, chunk_list, 0) != WEBP_MUX_OK) goto Err;
|
||||
}
|
||||
|
||||
{
|
||||
const size_t data_size = ChunkDiskSize(&chunk);
|
||||
data += data_size;
|
||||
size -= data_size;
|
||||
}
|
||||
ChunkInit(&chunk);
|
||||
}
|
||||
|
||||
// Validate mux if complete.
|
||||
@ -179,6 +179,7 @@ WebPMux* WebPMuxCreateInternal(const WebPData* const bitstream, int copy_data,
|
||||
return mux; // All OK;
|
||||
|
||||
Err: // Something bad happened.
|
||||
ChunkRelease(&chunk);
|
||||
MuxImageDelete(wpi);
|
||||
WebPMuxDelete(mux);
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user