WebPMuxCreate: fix unchecked malloc

Change-Id: Ic824cdfbede4abe8e5106904dd17d564bb1b32d4
This commit is contained in:
James Zern 2012-01-13 20:16:52 -08:00
parent eb425586e1
commit 7e4371c5b3
3 changed files with 4 additions and 1 deletions

View File

@ -174,7 +174,8 @@ uint8_t* ChunkListEmit(const WebPChunk* chunk_list, uint8_t* dst);
// Initialize.
void MuxImageInit(WebPMuxImage* const wpi);
// Delete image 'wpi'.
// Delete image 'wpi' and return the next image in the list or NULL.
// 'wpi' can be NULL.
WebPMuxImage* MuxImageDelete(WebPMuxImage* const wpi);
// Delete all images in 'wpi_list'.

View File

@ -345,6 +345,7 @@ WebPMuxError MuxImageSetNth(const WebPMuxImage* wpi, WebPMuxImage** wpi_list,
// MuxImage deletion methods.
WebPMuxImage* MuxImageDelete(WebPMuxImage* const wpi) {
// Delete the components of wpi. If wpi is NULL this is a noop.
WebPMuxImage* const next = MuxImageRelease(wpi);
free(wpi);
return next;

View File

@ -125,6 +125,7 @@ WebPMux* WebPMuxCreate(const uint8_t* data, uint32_t size, int copy_data,
size -= RIFF_HEADER_SIZE;
wpi = (WebPMuxImage*)malloc(sizeof(*wpi));
if (wpi == NULL) goto Err;
MuxImageInit(wpi);
// Loop over chunks.