diff mbox series

[FFmpeg-devel,4/5] avformat/rmdec: remove unneeded memset() on packet allocation

Message ID 20201102002128.6685-4-michael@niedermayer.cc
State Accepted
Headers show
Series [FFmpeg-devel,1/5] avformat/vqf: Check len for COMM chunks | expand

Checks

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

Commit Message

Michael Niedermayer Nov. 2, 2020, 12:21 a.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/rmdec.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Andreas Rheinhardt Nov. 2, 2020, 12:47 a.m. UTC | #1
Michael Niedermayer:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/rmdec.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
> index 9e954108f9..6a89143bc5 100644
> --- a/libavformat/rmdec.c
> +++ b/libavformat/rmdec.c
> @@ -817,7 +817,6 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
>          av_packet_unref(&vst->pkt); //FIXME this should be output.
>          if ((ret = av_new_packet(&vst->pkt, vst->videobufsize)) < 0)
>              return ret;
> -        memset(vst->pkt.data, 0, vst->pkt.size);
>          vst->videobufpos = 8*vst->slices + 1;
>          vst->cur_slice = 0;
>          vst->curpic_num = pic_num;
> 
Sure that this does not lead to uninitialized padding? Maybe use
av_shrink_packet() in line 852 instead of directly setting the size.

- Andreas
Michael Niedermayer Nov. 4, 2020, 7:59 a.m. UTC | #2
On Mon, Nov 02, 2020 at 01:47:25AM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/rmdec.c | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
> > index 9e954108f9..6a89143bc5 100644
> > --- a/libavformat/rmdec.c
> > +++ b/libavformat/rmdec.c
> > @@ -817,7 +817,6 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
> >          av_packet_unref(&vst->pkt); //FIXME this should be output.
> >          if ((ret = av_new_packet(&vst->pkt, vst->videobufsize)) < 0)
> >              return ret;
> > -        memset(vst->pkt.data, 0, vst->pkt.size);
> >          vst->videobufpos = 8*vst->slices + 1;
> >          vst->cur_slice = 0;
> >          vst->curpic_num = pic_num;
> > 
> Sure that this does not lead to uninitialized padding? Maybe use
> av_shrink_packet() in line 852 instead of directly setting the size.

hmm, av_shrink_packet() is a good idea either way so ill use that

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 9e954108f9..6a89143bc5 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -817,7 +817,6 @@  static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
         av_packet_unref(&vst->pkt); //FIXME this should be output.
         if ((ret = av_new_packet(&vst->pkt, vst->videobufsize)) < 0)
             return ret;
-        memset(vst->pkt.data, 0, vst->pkt.size);
         vst->videobufpos = 8*vst->slices + 1;
         vst->cur_slice = 0;
         vst->curpic_num = pic_num;