]> git.sesse.net Git - ffmpeg/commitdiff
imgutils: initialize palette padding bytes in av_image_alloc
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Tue, 12 May 2015 19:45:42 +0000 (21:45 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 13 May 2015 01:58:08 +0000 (03:58 +0200)
av_image_fill_pointers always aligns the palette, but the padding
bytes don't (and can't) get initialized in av_image_copy.

Thus initialize them in av_image_alloc.

This fixes 'Syscall param write(buf) points to uninitialised byte(s)'
valgrind warnings.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavutil/imgutils.c

index a8bc18d0256c65a1d1df49feed1fac217bc29fe0..ef0e67154b83c5fbd6b67b6625a07d5075377deb 100644 (file)
@@ -219,6 +219,14 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
     if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
         avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
 
+    if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
+         desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
+        pointers[1] - pointers[0] > linesizes[0] * h) {
+        /* zero-initialize the padding before the palette */
+        memset(pointers[0] + linesizes[0] * h, 0,
+               pointers[1] - pointers[0] - linesizes[0] * h);
+    }
+
     return ret;
 }