avcodec/decode: increase nb_bsfs after av_bsf_alloc in case alloc failed
authorLimin Wang <lance.lmwang@gmail.com>
Tue, 24 Dec 2019 01:06:18 +0000 (09:06 +0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 22 Mar 2020 12:00:19 +0000 (13:00 +0100)
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/decode.c

index 07b64b3..af6bb3f 100644 (file)
@@ -227,13 +227,13 @@ int ff_decode_bsfs_init(AVCodecContext *avctx)
             goto fail;
         }
         s->bsfs = tmp;
-        s->nb_bsfs++;
 
-        ret = av_bsf_alloc(filter, &s->bsfs[s->nb_bsfs - 1]);
+        ret = av_bsf_alloc(filter, &s->bsfs[s->nb_bsfs]);
         if (ret < 0) {
             av_freep(&bsf);
             goto fail;
         }
+        s->nb_bsfs++;
 
         if (s->nb_bsfs == 1) {
             /* We do not currently have an API for passing the input timebase into decoders,