mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
handle malloc(0) and calloc(0) uniformly on all platforms
also change lossless encoder logic, which was relying on explicit NULL return from WebPSafeMalloc(0) renamed function to CheckSizeArgumentsOverflow() explicitly addresses issue #138 Change-Id: Ibbd51cc0281e60e86dfd4c5496274399e4c0f7f3
This commit is contained in:
@ -221,7 +221,7 @@ static int GetHuffBitLengthsAndCodes(
|
||||
}
|
||||
|
||||
// Create Huffman trees.
|
||||
for (i = 0; i < histogram_image_size; ++i) {
|
||||
for (i = 0; ok && (i < histogram_image_size); ++i) {
|
||||
HuffmanTreeCode* const codes = &huffman_codes[5 * i];
|
||||
VP8LHistogram* const histo = histogram_image->histograms[i];
|
||||
ok = ok && VP8LCreateHuffmanTree(histo->literal_, 15, codes + 0);
|
||||
@ -232,7 +232,11 @@ static int GetHuffBitLengthsAndCodes(
|
||||
}
|
||||
|
||||
End:
|
||||
if (!ok) free(mem_buf);
|
||||
if (!ok) {
|
||||
free(mem_buf);
|
||||
// If one VP8LCreateHuffmanTree() above fails, we need to clean up behind.
|
||||
memset(huffman_codes, 0, 5 * histogram_image_size * sizeof(*huffman_codes));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user