diff mbox

[FFmpeg-devel,v2] avcodec/bsf: fix resource leak in av_bsf_list_parse_str

Message ID 20170110195646.22768-1-lq@chinaffmpeg.org
State Accepted
Commit d9c2cfd31675a6403ae4ac7c141a8185dadceb12
Headers show

Commit Message

Liu Steven Jan. 10, 2017, 7:56 p.m. UTC
cid: 1396268
when av_strdup(str) error, the lst need release

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavcodec/bsf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

James Almer Jan. 10, 2017, 8:04 p.m. UTC | #1
On 1/10/2017 4:56 PM, Steven Liu wrote:
> cid: 1396268
> when av_strdup(str) error, the lst need release
> 
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavcodec/bsf.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> index ac2024b..c984526 100644
> --- a/libavcodec/bsf.c
> +++ b/libavcodec/bsf.c
> @@ -514,8 +514,10 @@ int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
>      if (!lst)
>          return AVERROR(ENOMEM);
>  
> -    if (!(dup = buf = av_strdup(str)))
> -        return AVERROR(ENOMEM);
> +    if (!(dup = buf = av_strdup(str))) {
> +        ret = AVERROR(ENOMEM);
> +        goto end;
> +    }
>  
>      while (1) {
>          bsf_str = av_strtok(buf, ",", &saveptr);
> 

LGTM.
Steven Liu Jan. 10, 2017, 8:11 p.m. UTC | #2
2017-01-11 4:04 GMT+08:00 James Almer <jamrial@gmail.com>:

> On 1/10/2017 4:56 PM, Steven Liu wrote:
> > cid: 1396268
> > when av_strdup(str) error, the lst need release
> >
> > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > ---
> >  libavcodec/bsf.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> > index ac2024b..c984526 100644
> > --- a/libavcodec/bsf.c
> > +++ b/libavcodec/bsf.c
> > @@ -514,8 +514,10 @@ int av_bsf_list_parse_str(const char *str,
> AVBSFContext **bsf_lst)
> >      if (!lst)
> >          return AVERROR(ENOMEM);
> >
> > -    if (!(dup = buf = av_strdup(str)))
> > -        return AVERROR(ENOMEM);
> > +    if (!(dup = buf = av_strdup(str))) {
> > +        ret = AVERROR(ENOMEM);
> > +        goto end;
> > +    }
> >
> >      while (1) {
> >          bsf_str = av_strtok(buf, ",", &saveptr);
> >
>
> LGTM.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

applied!




Thanks!
diff mbox

Patch

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index ac2024b..c984526 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -514,8 +514,10 @@  int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
     if (!lst)
         return AVERROR(ENOMEM);
 
-    if (!(dup = buf = av_strdup(str)))
-        return AVERROR(ENOMEM);
+    if (!(dup = buf = av_strdup(str))) {
+        ret = AVERROR(ENOMEM);
+        goto end;
+    }
 
     while (1) {
         bsf_str = av_strtok(buf, ",", &saveptr);