[FFmpeg-devel] [PATCH] vp3: zero allocated tables

Michael Niedermayer michaelni at gmx.at
Fri May 17 20:04:14 CEST 2013


On Fri, May 17, 2013 at 12:51:14PM +0000, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> 
> See ticket #2527.
> 
> ---
>  libavcodec/vp3.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index 5bf2fee..fe4e48b 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -1632,16 +1632,16 @@ static av_cold int allocate_tables(AVCodecContext *avctx)
>      y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
>      c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
>  
> -    s->superblock_coding = av_malloc(s->superblock_count);
> -    s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
> -    s->coded_fragment_list[0] = av_malloc(s->fragment_count * sizeof(int));
> -    s->dct_tokens_base = av_malloc(64*s->fragment_count * sizeof(*s->dct_tokens_base));
> -    s->motion_val[0] = av_malloc(y_fragment_count * sizeof(*s->motion_val[0]));
> -    s->motion_val[1] = av_malloc(c_fragment_count * sizeof(*s->motion_val[1]));
> +    s->superblock_coding = av_mallocz(s->superblock_count);
> +    s->all_fragments = av_mallocz(s->fragment_count * sizeof(Vp3Fragment));
> +    s->coded_fragment_list[0] = av_mallocz(s->fragment_count * sizeof(int));

> +    s->dct_tokens_base = av_mallocz(64*s->fragment_count * sizeof(*s->dct_tokens_base));

this one alone is sufficient to fix the valgrind issue from ticket
2527

i dont mind if all are zeroed on allocation though, it might simplify
debuging to have deterministic values

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- 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/20130517/232f491c/attachment.asc>


More information about the ffmpeg-devel mailing list