On 12.05.2015 21:12, Michael Niedermayer wrote:
> On Tue, May 12, 2015 at 04:02:44PM +0200, Andreas Cadhalpun wrote:
>> On 12.05.2015 14:51, Michael Niedermayer wrote:
>>> On Tue, May 12, 2015 at 02:31:38PM +0200, Andreas Cadhalpun wrote:
>>>> @@ -108,6 +109,14 @@ static int decode_packet(int *got_frame, int cached)
>>>> (const uint8_t **)(frame->data),
>>>> frame->linesize,
>>>> pix_fmt, width, height);
>>>>
>>>> + if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
>>>> + desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
>>>> + video_dst_data[1] - video_dst_data[0] >
>>>> video_dst_linesize[0] * height) {
>>>> + /* zero-initialize the padding before the palette */
>>>> + memset(video_dst_data[0] + video_dst_linesize[0] *
>>>> height, 0,
>>>> + video_dst_data[1] - video_dst_data[0] -
>>>> video_dst_linesize[0] * height);
>>>> + }
>>>
>>> i wonder if this shouldnt be moved to av_image_alloc() ?
>>
>> It's a bit nicer to do this in av_image_fill_pointers.
>
> yes but thats not safe
>
> for example rawdec calls avpicture_fill() on the input buffer
> which uses av_image_fill_pointers()
OK, then let's do it in av_image_alloc.
Best regards,
Andreas
>From c244cba6812bcb15f871b72e721fc3310f6c983f Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <[email protected]>
Date: Tue, 12 May 2015 21:45:42 +0200
Subject: [PATCH] imgutils: initialize palette padding bytes in av_image_alloc
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 <[email protected]>
---
libavutil/imgutils.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index a8bc18d..ef0e671 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -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;
}
--
2.1.4
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel