From acd8ba4229dd46346eb13538b5480321e8eacde2 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Wed, 20 Jul 2011 07:49:57 -0700 Subject: [PATCH] io->teardown() was not always called upon error Change-Id: I8317139b583124fc20754b9b19aa4dba51cd05af --- src/dec/idec.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/dec/idec.c b/src/dec/idec.c index 628ff611..1e51f0d7 100644 --- a/src/dec/idec.c +++ b/src/dec/idec.c @@ -229,6 +229,12 @@ static void RestoreContext(const MBContext* context, VP8Decoder* const dec, //------------------------------------------------------------------------------ static VP8StatusCode IDecError(WebPIDecoder* idec, VP8StatusCode error) { + if (idec->state_ == STATE_DATA) { + VP8Io* const io = &idec->io_; + if (io->teardown) { + io->teardown(io); + } + } idec->state_ = STATE_ERROR; return error; } @@ -323,14 +329,16 @@ static VP8StatusCode DecodePartition0(WebPIDecoder* const idec) { return IDecError(idec, dec->status_); } - // Finish setting up the decoding parameter - if (VP8FinishFrameSetup(dec, io) != VP8_STATUS_OK) { - return IDecError(idec, dec->status_); - } - if (!CopyParts0Data(idec)) { return IDecError(idec, VP8_STATUS_OUT_OF_MEMORY); } + + // Finish setting up the decoding parameters. + if (VP8FinishFrameSetup(dec, io) != VP8_STATUS_OK) { + return IDecError(idec, dec->status_); + } + // Note: past this point, teardown() must always be called + // in case of error. idec->state_ = STATE_DATA; return VP8_STATUS_OK; }