diff mbox series

[FFmpeg-devel] libavcodec/mpeg12dec.c: Switch to init_get_bits8 and checks return value

Message ID 20210722180851.3676990-1-tfoucu@gmail.com
State New
Headers show
Series [FFmpeg-devel] libavcodec/mpeg12dec.c: Switch to init_get_bits8 and checks return value | expand

Checks

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

Commit Message

Thierry Foucu July 22, 2021, 6:08 p.m. UTC
---
 libavcodec/mpeg12dec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer July 23, 2021, 9:13 p.m. UTC | #1
On Thu, Jul 22, 2021 at 11:08:51AM -0700, Thierry Foucu wrote:
> ---
>  libavcodec/mpeg12dec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> index b27ed5bd6d..269619540a 100644
> --- a/libavcodec/mpeg12dec.c
> +++ b/libavcodec/mpeg12dec.c
> @@ -1341,8 +1341,11 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf,
>      Mpeg1Context *s1  = avctx->priv_data;
>      MpegEncContext *s = &s1->mpeg_enc_ctx;
>      int ref, f_code, vbv_delay;

> +    int ret = 0;
> +        ret = init_get_bits8(&s->gb, buf, buf_size);

redundant assignment

thx

[...]
Thierry Foucu July 27, 2021, 6:24 p.m. UTC | #2
On Fri, Jul 23, 2021 at 2:13 PM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> On Thu, Jul 22, 2021 at 11:08:51AM -0700, Thierry Foucu wrote:
> > ---
> >  libavcodec/mpeg12dec.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> > index b27ed5bd6d..269619540a 100644
> > --- a/libavcodec/mpeg12dec.c
> > +++ b/libavcodec/mpeg12dec.c
> > @@ -1341,8 +1341,11 @@ static int mpeg1_decode_picture(AVCodecContext
> *avctx, const uint8_t *buf,
> >      Mpeg1Context *s1  = avctx->priv_data;
> >      MpegEncContext *s = &s1->mpeg_enc_ctx;
> >      int ref, f_code, vbv_delay;
>
> > +    int ret = 0;
> > +        ret = init_get_bits8(&s->gb, buf, buf_size);
>
> redundant assignment
>

Sorry, will send new patch.

>
> thx
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Rewriting code that is poorly written but fully understood is good.
> Rewriting code that one doesnt understand is a sign that one is less smart
> than the original author, trying to rewrite it will not make it better.
> _______________________________________________
> 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/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index b27ed5bd6d..269619540a 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1341,8 +1341,11 @@  static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf,
     Mpeg1Context *s1  = avctx->priv_data;
     MpegEncContext *s = &s1->mpeg_enc_ctx;
     int ref, f_code, vbv_delay;
+    int ret = 0;
 
-    init_get_bits(&s->gb, buf, buf_size * 8);
+    ret = init_get_bits8(&s->gb, buf, buf_size);
+    if (ret < 0)
+        return ret;
 
     ref = get_bits(&s->gb, 10); /* temporal ref */
     s->pict_type = get_bits(&s->gb, 3);