[FFmpeg-devel] [PATCH 1/2] lavfi/showspectrum: fix crash in case of negative linesize
Paul B Mahol
onemda at gmail.com
Mon Apr 29 20:40:43 CEST 2013
On 4/29/13, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Mon, Apr 29, 2013 at 01:39:44PM +0000, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>> libavfilter/avf_showspectrum.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavfilter/avf_showspectrum.c
>> b/libavfilter/avf_showspectrum.c
>> index 058f22c..c87812f 100644
>> --- a/libavfilter/avf_showspectrum.c
>> +++ b/libavfilter/avf_showspectrum.c
>> @@ -211,9 +211,11 @@ static int config_output(AVFilterLink *outlink)
>> if (!outpicref)
>> return AVERROR(ENOMEM);
>> outlink->sample_aspect_ratio = (AVRational){1,1};
>> - memset(outpicref->data[0], 0, outlink->h *
>> outpicref->linesize[0]);
>> - memset(outpicref->data[1], 128, outlink->h *
>> outpicref->linesize[1]);
>> - memset(outpicref->data[2], 128, outlink->h *
>> outpicref->linesize[2]);
>> + for (i = 0; i < outlink->h; i++) {
>> + memset(outpicref->data[0] + i * outpicref->linesize[0], 0,
>> FFABS(outpicref->linesize[0]));
>> + memset(outpicref->data[1] + i * outpicref->linesize[1], 128,
>> FFABS(outpicref->linesize[1]));
>> + memset(outpicref->data[2] + i * outpicref->linesize[2], 128,
>> FFABS(outpicref->linesize[2]));
>
> width * "pixel size" is more correct than linesize
> (linesize could be for 2 lines in a field of a interlaced frame
>
> otherwise LGTM
Is this new truth?
I don't see sanity behind such reasoning. This filter is not (i hope) going
to do any such nonsense with fieds anytime soon and thus such complicated code
is not required.
I could even commit simplified version without loop.
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> I do not agree with what you have to say, but I'll defend to the death your
> right to say it. -- Voltaire
>
More information about the ffmpeg-devel
mailing list