From 8a9972353da5e102f395c48ea9325c6ba508219e 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: I8d77069aadc594758aaa79b2b73376c0107e57e4 --- 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 affd91ce..5e8185e2 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -530,7 +530,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,