[FFmpeg-cvslog] avcodec/truemotion2: Cleanup generically on init failure

Andreas Rheinhardt git at videolan.org
Sat Nov 7 03:05:25 EET 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun Sep 27 14:33:40 2020 +0200| [fa1d105a6c44b75f583b1b3870d83aca69caee95] | committer: Andreas Rheinhardt

avcodec/truemotion2: Cleanup generically on init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa1d105a6c44b75f583b1b3870d83aca69caee95
---

 libavcodec/truemotion2.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 1ae13bbf06..a90ff8cf01 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -984,15 +984,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
     if (!l->Y1_base || !l->Y2_base || !l->U1_base ||
         !l->V1_base || !l->U2_base || !l->V2_base ||
         !l->last    || !l->clast) {
-        av_freep(&l->Y1_base);
-        av_freep(&l->Y2_base);
-        av_freep(&l->U1_base);
-        av_freep(&l->U2_base);
-        av_freep(&l->V1_base);
-        av_freep(&l->V2_base);
-        av_freep(&l->last);
-        av_freep(&l->clast);
-        av_frame_free(&l->pic);
         return AVERROR(ENOMEM);
     }
     l->Y1 = l->Y1_base + l->y_stride  * 4 + 4;
@@ -1014,14 +1005,13 @@ static av_cold int decode_end(AVCodecContext *avctx)
     av_freep(&l->clast);
     for (i = 0; i < TM2_NUM_STREAMS; i++)
         av_freep(&l->tokens[i]);
-    if (l->Y1) {
+
         av_freep(&l->Y1_base);
         av_freep(&l->U1_base);
         av_freep(&l->V1_base);
         av_freep(&l->Y2_base);
         av_freep(&l->U2_base);
         av_freep(&l->V2_base);
-    }
     av_freep(&l->buffer);
     l->buffer_size = 0;
 
@@ -1040,4 +1030,5 @@ AVCodec ff_truemotion2_decoder = {
     .close          = decode_end,
     .decode         = decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };



More information about the ffmpeg-cvslog mailing list