Merge "add a malloc() check" into 0.2.0

This commit is contained in:
James Zern 2012-07-16 19:18:28 -07:00 committed by Gerrit Code Review
commit ab2da3e9fd

View File

@ -890,11 +890,21 @@ static int DecodeImageStream(int xsize, int ysize,
goto End; goto End;
} }
data = (uint32_t*)malloc(transform_xsize * transform_ysize * sizeof(*data)); {
if (data == NULL) { const uint64_t total_size =
dec->status_ = VP8_STATUS_OUT_OF_MEMORY; transform_xsize * transform_ysize * sizeof(*data);
ok = 0; if (total_size != (size_t)total_size) {
goto End; // 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) {
dec->status_ = VP8_STATUS_OUT_OF_MEMORY;
ok = 0;
goto End;
}
} }
// Use the Huffman trees to decode the LZ77 encoded data. // Use the Huffman trees to decode the LZ77 encoded data.