diff mbox series

[FFmpeg-devel,3/7] avformat/icodec: Factor failure code out in read_header()

Message ID 20201104000649.14740-3-michael@niedermayer.cc
State Accepted
Commit 27ee67c00f4402030af3b7477dd5088464d31d80
Headers show
Series [FFmpeg-devel,1/7] avformat/mpc8: correct 32bit timestamp truncation | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Michael Niedermayer Nov. 4, 2020, 12:06 a.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/icodec.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Peter Ross Nov. 13, 2020, 6:36 a.m. UTC | #1
On Wed, Nov 04, 2020 at 01:06:45AM +0100, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/icodec.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/icodec.c b/libavformat/icodec.c
> index c061f3ec42..cf1e60815e 100644
> --- a/libavformat/icodec.c
> +++ b/libavformat/icodec.c
> @@ -113,8 +113,7 @@ static int read_header(AVFormatContext *s)
>          ico->images[i].size   = avio_rl32(pb);
>          if (ico->images[i].size <= 0) {
>              av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size);
> -            av_freep(&ico->images);
> -            return AVERROR_INVALIDDATA;
> +            goto fail;
>          }
>          ico->images[i].offset = avio_rl32(pb);
>  
> @@ -130,8 +129,7 @@ static int read_header(AVFormatContext *s)
>              break;
>          case 40:
>              if (ico->images[i].size < 40) {
> -                av_freep(&ico->images);
> -                return AVERROR_INVALIDDATA;
> +                goto fail;
>              }
>              st->codecpar->codec_id = AV_CODEC_ID_BMP;
>              tmp = avio_rl32(pb);
> @@ -143,12 +141,14 @@ static int read_header(AVFormatContext *s)
>              break;
>          default:
>              avpriv_request_sample(s, "codec %d", codec);
> -            av_freep(&ico->images);
> -            return AVERROR_INVALIDDATA;
> +            goto fail;
>          }
>      }
>  
>      return 0;
> +fail:
> +    av_freep(&ico->images);
> +    return AVERROR_INVALIDDATA;
>  }
>  
>  static int read_packet(AVFormatContext *s, AVPacket *pkt)
> -- 
> 2.17.1

looks good

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Michael Niedermayer Nov. 13, 2020, 5:02 p.m. UTC | #2
On Fri, Nov 13, 2020 at 05:36:59PM +1100, Peter Ross wrote:
> On Wed, Nov 04, 2020 at 01:06:45AM +0100, Michael Niedermayer wrote:
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/icodec.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/libavformat/icodec.c b/libavformat/icodec.c
> > index c061f3ec42..cf1e60815e 100644
> > --- a/libavformat/icodec.c
> > +++ b/libavformat/icodec.c
> > @@ -113,8 +113,7 @@ static int read_header(AVFormatContext *s)
> >          ico->images[i].size   = avio_rl32(pb);
> >          if (ico->images[i].size <= 0) {
> >              av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size);
> > -            av_freep(&ico->images);
> > -            return AVERROR_INVALIDDATA;
> > +            goto fail;
> >          }
> >          ico->images[i].offset = avio_rl32(pb);
> >  
> > @@ -130,8 +129,7 @@ static int read_header(AVFormatContext *s)
> >              break;
> >          case 40:
> >              if (ico->images[i].size < 40) {
> > -                av_freep(&ico->images);
> > -                return AVERROR_INVALIDDATA;
> > +                goto fail;
> >              }
> >              st->codecpar->codec_id = AV_CODEC_ID_BMP;
> >              tmp = avio_rl32(pb);
> > @@ -143,12 +141,14 @@ static int read_header(AVFormatContext *s)
> >              break;
> >          default:
> >              avpriv_request_sample(s, "codec %d", codec);
> > -            av_freep(&ico->images);
> > -            return AVERROR_INVALIDDATA;
> > +            goto fail;
> >          }
> >      }
> >  
> >      return 0;
> > +fail:
> > +    av_freep(&ico->images);
> > +    return AVERROR_INVALIDDATA;
> >  }
> >  
> >  static int read_packet(AVFormatContext *s, AVPacket *pkt)
> > -- 
> > 2.17.1
> 
> looks good

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index c061f3ec42..cf1e60815e 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -113,8 +113,7 @@  static int read_header(AVFormatContext *s)
         ico->images[i].size   = avio_rl32(pb);
         if (ico->images[i].size <= 0) {
             av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size);
-            av_freep(&ico->images);
-            return AVERROR_INVALIDDATA;
+            goto fail;
         }
         ico->images[i].offset = avio_rl32(pb);
 
@@ -130,8 +129,7 @@  static int read_header(AVFormatContext *s)
             break;
         case 40:
             if (ico->images[i].size < 40) {
-                av_freep(&ico->images);
-                return AVERROR_INVALIDDATA;
+                goto fail;
             }
             st->codecpar->codec_id = AV_CODEC_ID_BMP;
             tmp = avio_rl32(pb);
@@ -143,12 +141,14 @@  static int read_header(AVFormatContext *s)
             break;
         default:
             avpriv_request_sample(s, "codec %d", codec);
-            av_freep(&ico->images);
-            return AVERROR_INVALIDDATA;
+            goto fail;
         }
     }
 
     return 0;
+fail:
+    av_freep(&ico->images);
+    return AVERROR_INVALIDDATA;
 }
 
 static int read_packet(AVFormatContext *s, AVPacket *pkt)