diff mbox

[FFmpeg-devel,v1] avcodec/decode: increase nb_bsfs after av_bsf_alloc in case alloc failed

Message ID 20191224010618.28454-1-lance.lmwang@gmail.com
State Accepted
Headers show

Commit Message

Limin Wang Dec. 24, 2019, 1:06 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/decode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Limin Wang March 21, 2020, 9:14 a.m. UTC | #1
ping for review, thanks.

On Tue, Dec 24, 2019 at 09:06:18AM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/decode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index cd275bacc4..1ebbca4724 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -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,
> -- 
> 2.21.0
>
Michael Niedermayer March 22, 2020, 12:03 p.m. UTC | #2
On Tue, Dec 24, 2019 at 09:06:18AM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/decode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

thx


[...]
diff mbox

Patch

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index cd275bacc4..1ebbca4724 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -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,