diff mbox series

[FFmpeg-devel,4/6] avformat/au: check return value of au_read_annotation()

Message ID 1592839474-2804-4-git-send-email-lance.lmwang@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/6] avutil/opt: check return value of av_bprint_finalize() | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Lance Wang June 22, 2020, 3:24 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/au.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Marton Balint June 22, 2020, 9:15 p.m. UTC | #1
On Mon, 22 Jun 2020, lance.lmwang@gmail.com wrote:

> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
> libavformat/au.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/au.c b/libavformat/au.c
> index ff9176a..b6df63e 100644
> --- a/libavformat/au.c
> +++ b/libavformat/au.c
> @@ -145,6 +145,7 @@ static int au_read_header(AVFormatContext *s)
>     int bps, ba = 0;
>     enum AVCodecID codec;
>     AVStream *st;
> +    int ret;
>
>     tag = avio_rl32(pb);
>     if (tag != MKTAG('.', 's', 'n', 'd'))
> @@ -163,7 +164,8 @@ static int au_read_header(AVFormatContext *s)
>
>     if (size > 24) {
>         /* parse annotation field to get metadata */
> -        au_read_annotation(s, size - 24);
> +        if (ret = au_read_annotation(s, size - 24) < 0)

Use two lines for the assignment and the check, otherwise sooner or later 
you will make an operator precedence mistake.

Regards,
Marton

> +            return ret;
>     }
>
>     codec = ff_codec_get_id(codec_au_tags, id);
> -- 
> 1.8.3.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Lance Wang June 22, 2020, 11:10 p.m. UTC | #2
On Mon, Jun 22, 2020 at 11:15:12PM +0200, Marton Balint wrote:
> 
> 
> On Mon, 22 Jun 2020, lance.lmwang@gmail.com wrote:
> 
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> > libavformat/au.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/au.c b/libavformat/au.c
> > index ff9176a..b6df63e 100644
> > --- a/libavformat/au.c
> > +++ b/libavformat/au.c
> > @@ -145,6 +145,7 @@ static int au_read_header(AVFormatContext *s)
> >     int bps, ba = 0;
> >     enum AVCodecID codec;
> >     AVStream *st;
> > +    int ret;
> > 
> >     tag = avio_rl32(pb);
> >     if (tag != MKTAG('.', 's', 'n', 'd'))
> > @@ -163,7 +164,8 @@ static int au_read_header(AVFormatContext *s)
> > 
> >     if (size > 24) {
> >         /* parse annotation field to get metadata */
> > -        au_read_annotation(s, size - 24);
> > +        if (ret = au_read_annotation(s, size - 24) < 0)
> 
> Use two lines for the assignment and the check, otherwise sooner or later
> you will make an operator precedence mistake.

thanks, will fix it.


> 
> Regards,
> Marton
> 
> > +            return ret;
> >     }
> > 
> >     codec = ff_codec_get_id(codec_au_tags, id);
> > -- 
> > 1.8.3.1
> > 
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/au.c b/libavformat/au.c
index ff9176a..b6df63e 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -145,6 +145,7 @@  static int au_read_header(AVFormatContext *s)
     int bps, ba = 0;
     enum AVCodecID codec;
     AVStream *st;
+    int ret;
 
     tag = avio_rl32(pb);
     if (tag != MKTAG('.', 's', 'n', 'd'))
@@ -163,7 +164,8 @@  static int au_read_header(AVFormatContext *s)
 
     if (size > 24) {
         /* parse annotation field to get metadata */
-        au_read_annotation(s, size - 24);
+        if (ret = au_read_annotation(s, size - 24) < 0)
+            return ret;
     }
 
     codec = ff_codec_get_id(codec_au_tags, id);