mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-25 13:18:22 +01:00
libwebp: do not destroy jpeg codec twice on error
WebPPictureImportRGB() can fail on memory allocation. In this case, jpeg_destroy_decompress() was already called, so do not go to Error. Free metadata as an error is returned. Change-Id: I045b072090e9063d3ad10369ad18b0f08bdffe9f
This commit is contained in:
parent
faf219684c
commit
6e8a4126f2
@ -336,7 +336,11 @@ int ReadJPEG(const uint8_t* const data, size_t data_size,
|
||||
pic->width = width;
|
||||
pic->height = height;
|
||||
ok = WebPPictureImportRGB(pic, rgb, (int)stride);
|
||||
if (!ok) goto Error;
|
||||
if (!ok) {
|
||||
pic->width = 0; // WebPPictureImportRGB() barely touches 'pic' on failure.
|
||||
pic->height = 0; // Just reset dimensions but keep any 'custom_ptr' etc.
|
||||
MetadataFree(metadata); // In case the caller forgets to free it on error.
|
||||
}
|
||||
|
||||
End:
|
||||
free(rgb);
|
||||
|
Loading…
Reference in New Issue
Block a user