From 0b18b9eef667b5359f6f44581de92a09d78142d3 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 22 May 2013 00:58:53 +0200 Subject: [PATCH] fix two minor memory leaks in webpmux (only occur in case of error) Change-Id: Icab69bb364b77f8eae6cae91047354c27e610602 (cherry picked from commit 3e59a74d721ed15c8845c9c1215dcb09fdb55fa6) --- examples/webpmux.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/webpmux.c b/examples/webpmux.c index 40592f27..b17d6a6e 100644 --- a/examples/webpmux.c +++ b/examples/webpmux.c @@ -226,11 +226,13 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) { for (i = 1; i <= nFrames; i++) { WebPMuxFrameInfo frame; err = WebPMuxGetFrame(mux, i, &frame); - RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i); - printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset); - if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method); - printf("%10d\n", (int)frame.bitstream.size); + if (err == WEBP_MUX_OK) { + printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset); + if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method); + printf("%10d\n", (int)frame.bitstream.size); + } WebPDataClear(&frame.bitstream); + RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i); } } } @@ -259,8 +261,11 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) { if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | FRAGMENTS_FLAG))) { WebPMuxFrameInfo image; err = WebPMuxGetFrame(mux, 1, &image); + if (err == WEBP_MUX_OK) { + printf("Size of the image (with alpha): %d\n", (int)image.bitstream.size); + } + WebPDataClear(&image.bitstream); RETURN_IF_ERROR("Failed to retrieve the image\n"); - printf("Size of the image (with alpha): %d\n", (int)image.bitstream.size); } return WEBP_MUX_OK;