diff mbox

[FFmpeg-devel,1/3] lavf/vividas: check avformat_new_stream() return

Message ID 1574948460-15981-1-git-send-email-mypopydev@gmail.com
State Accepted
Commit d96558902277a25e002ad1b9bb9bc7e536a13a8b
Headers show

Commit Message

Jun Zhao Nov. 28, 2019, 1:40 p.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

check avformat_new_stream() return.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/vividas.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Comments

Andreas Rheinhardt Nov. 28, 2019, 2:08 p.m. UTC | #1
Jun Zhao:
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> check avformat_new_stream() return.
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavformat/vividas.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/vividas.c b/libavformat/vividas.c
> index f20af3d..16642c0 100644
> --- a/libavformat/vividas.c
> +++ b/libavformat/vividas.c
> @@ -319,6 +319,8 @@ static int track_header(VividasDemuxContext *viv, AVFormatContext *s,  uint8_t *
>  
>      for (i = 0; i < num_video; i++) {
>          AVStream *st = avformat_new_stream(s, NULL);
> +        if (!st)
> +            return AVERROR(ENOMEM);
>  
>          st->id = i;
>  
> @@ -352,6 +354,8 @@ static int track_header(VividasDemuxContext *viv, AVFormatContext *s,  uint8_t *
>      for(i=0;i<viv->num_audio;i++) {
>          int q;
>          AVStream *st = avformat_new_stream(s, NULL);
> +        if (!st)
> +            return AVERROR(ENOMEM);
>  
>          st->id = num_video + i;
>  
> 
Actually, the AVIOContext pb leaks when these errors happen. But don't
bother updating your patch, because pb should actually not be
allocated at all: I'll send a patch using ffio_init_context soon.

- Andreas
Michael Niedermayer Nov. 28, 2019, 10:59 p.m. UTC | #2
On Thu, Nov 28, 2019 at 09:40:58PM +0800, Jun Zhao wrote:
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> check avformat_new_stream() return.
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavformat/vividas.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)

LGTM

thx


[...]
mypopy@gmail.com Nov. 29, 2019, 2:08 a.m. UTC | #3
On Thu, Nov 28, 2019 at 10:37 PM Andreas Rheinhardt
<andreas.rheinhardt@gmail.com> wrote:
>
> Jun Zhao:
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > check avformat_new_stream() return.
> >
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> >  libavformat/vividas.c |    4 ++++
> >  1 files changed, 4 insertions(+), 0 deletions(-)
> >
> > diff --git a/libavformat/vividas.c b/libavformat/vividas.c
> > index f20af3d..16642c0 100644
> > --- a/libavformat/vividas.c
> > +++ b/libavformat/vividas.c
> > @@ -319,6 +319,8 @@ static int track_header(VividasDemuxContext *viv, AVFormatContext *s,  uint8_t *
> >
> >      for (i = 0; i < num_video; i++) {
> >          AVStream *st = avformat_new_stream(s, NULL);
> > +        if (!st)
> > +            return AVERROR(ENOMEM);
> >
> >          st->id = i;
> >
> > @@ -352,6 +354,8 @@ static int track_header(VividasDemuxContext *viv, AVFormatContext *s,  uint8_t *
> >      for(i=0;i<viv->num_audio;i++) {
> >          int q;
> >          AVStream *st = avformat_new_stream(s, NULL);
> > +        if (!st)
> > +            return AVERROR(ENOMEM);
> >
> >          st->id = num_video + i;
> >
> >
> Actually, the AVIOContext pb leaks when these errors happen. But don't
> bother updating your patch, because pb should actually not be
> allocated at all: I'll send a patch using ffio_init_context soon.
>
I think you comments the other patch :), and Michael have applied your patch
mypopy@gmail.com Nov. 29, 2019, 2:13 a.m. UTC | #4
On Fri, Nov 29, 2019 at 6:59 AM Michael Niedermayer
<michael@niedermayer.cc> wrote:
>
> On Thu, Nov 28, 2019 at 09:40:58PM +0800, Jun Zhao wrote:
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > check avformat_new_stream() return.
> >
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> >  libavformat/vividas.c |    4 ++++
> >  1 files changed, 4 insertions(+), 0 deletions(-)
>
> LGTM
>
> thx
>

Applied, thx
diff mbox

Patch

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index f20af3d..16642c0 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -319,6 +319,8 @@  static int track_header(VividasDemuxContext *viv, AVFormatContext *s,  uint8_t *
 
     for (i = 0; i < num_video; i++) {
         AVStream *st = avformat_new_stream(s, NULL);
+        if (!st)
+            return AVERROR(ENOMEM);
 
         st->id = i;
 
@@ -352,6 +354,8 @@  static int track_header(VividasDemuxContext *viv, AVFormatContext *s,  uint8_t *
     for(i=0;i<viv->num_audio;i++) {
         int q;
         AVStream *st = avformat_new_stream(s, NULL);
+        if (!st)
+            return AVERROR(ENOMEM);
 
         st->id = num_video + i;