[FFmpeg-devel] [PATCH 1/3] Replace DUP_DATA & memset with 0 by av_mallocz

Michael Niedermayer michaelni at gmx.at
Mon Sep 17 22:25:43 CEST 2012


On Mon, Sep 17, 2012 at 07:55:01PM +0300, Andrey Utkin wrote:
> Offtop childish question: does malloc(struct_size * number) always alloc same size as calloc(number, struct_size)? I.e. is having two params in calloc() a nonsense?
> ---8<---
> ---
>  libavcodec/avpacket.c |    5 +----
>  1 files changed, 1 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> index dbbba56..03754c5 100644
> --- a/libavcodec/avpacket.c
> +++ b/libavcodec/avpacket.c
> @@ -140,10 +140,7 @@ int av_dup_packet(AVPacket *pkt)
>          if (pkt->side_data_elems) {
>              int i;
>  
> -            DUP_DATA(pkt->side_data, tmp_pkt.side_data,
> -                     pkt->side_data_elems * sizeof(*pkt->side_data), 0);
> -            memset(pkt->side_data, 0,
> -                   pkt->side_data_elems * sizeof(*pkt->side_data));
> +            pkt->side_data = av_mallocz(pkt->side_data_elems * sizeof(*pkt->side_data));

this looses the null ptr / malloc failure check from inside 
DUP_DATA()


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120917/e7bb2997/attachment.asc>


More information about the ffmpeg-devel mailing list