mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
add a malloc() check
mostly a sanity measure to be future-proof Change-Id: I55a81345819b2a8e939c98f0da883dc5c0cc16a2
This commit is contained in:
parent
8130c4cc64
commit
2d571bd89f
@ -890,12 +890,22 @@ static int DecodeImageStream(int xsize, int ysize,
|
|||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (uint32_t*)malloc(transform_xsize * transform_ysize * sizeof(*data));
|
{
|
||||||
|
const uint64_t total_size =
|
||||||
|
transform_xsize * transform_ysize * sizeof(*data);
|
||||||
|
if (total_size != (size_t)total_size) {
|
||||||
|
// This shouldn't happen, because of transform_bits limit, but...
|
||||||
|
dec->status_ = VP8_STATUS_BITSTREAM_ERROR;
|
||||||
|
ok = 0;
|
||||||
|
goto End;
|
||||||
|
}
|
||||||
|
data = (uint32_t*)malloc((size_t)total_size);
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
|
dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
|
||||||
ok = 0;
|
ok = 0;
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Use the Huffman trees to decode the LZ77 encoded data.
|
// Use the Huffman trees to decode the LZ77 encoded data.
|
||||||
ok = DecodeImageData(dec, data, transform_xsize, transform_ysize, NULL);
|
ok = DecodeImageData(dec, data, transform_xsize, transform_ysize, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user