From b30add201700cfdd3188b6a5e18bbbc3c41028ef Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 3 Oct 2012 12:06:33 -0700 Subject: [PATCH] EncodeImageInternal: fix uninitialized free on allocation error refs.refs would be uninitialized and free'd, causing a crash Change-Id: Idb7daec7aec3e5d769d8103595c28a9d0d0b86f4 --- src/enc/vp8l.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 9c202f8d..7abc3b95 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -529,7 +529,12 @@ static int EncodeImageInternal(VP8LBitWriter* const bw, sizeof(*histogram_symbols)); assert(histogram_bits >= MIN_HUFFMAN_BITS); assert(histogram_bits <= MAX_HUFFMAN_BITS); - if (histogram_image == NULL || histogram_symbols == NULL) goto Error; + + if (histogram_image == NULL || histogram_symbols == NULL) { + free(histogram_image); + free(histogram_symbols); + return 0; + } // Calculate backward references from ARGB image. if (!VP8LGetBackwardReferences(width, height, argb, quality, cache_bits,