[FFmpeg-devel] [PATCH 1/2] lavfi/showspectrum: fix crash in case of negative linesize

Michael Niedermayer michaelni at gmx.at
Mon Apr 29 20:05:12 CEST 2013


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

[...]
-- 
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
-------------- 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/20130429/804f10f1/attachment.asc>


More information about the ffmpeg-devel mailing list