[FFmpeg-devel] [PATCH] jpeg2000: fix for uninitialized data errors in valgrind/memcheck

Michael Niedermayer michaelni at gmx.at
Thu May 2 23:36:34 CEST 2013


On Mon, Apr 29, 2013 at 12:25:09PM +0200, Nicolas Bertrand wrote:
> ---
>  libavcodec/jpeg2000dec.c |   18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index c1bd772..7b902fa 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -632,7 +632,14 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
>              Jpeg2000Cblk *cblk = prec->cblk + cblkno;
>              if (s->buf_end - s->buf < cblk->lengthinc)
>                  return AVERROR(EINVAL);
> -            bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc);
> +            /* A code-block data can be empty. In that case initialize data
> +             * with 0xffff. */
> +            if (cblk->lengthinc > 0)
> +                bytestream_get_buffer(&s->buf, cblk->data, cblk->lengthinc);
> +            else {
> +                cblk->data[0] = 0xff;
> +                cblk->data[1] = 0xff;
> +            }

is this also working for lengthinc == 1 ?

and if you want me to merge some branch from some git repo with
jpeg2000 changes into ffmpeg please say so.

Also, there are other valgrind warnings from the jpeg2000 decoder.
It seems its missing needed cleanup on error and leaking memory

Thanks
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- 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/20130502/1469b9db/attachment.asc>


More information about the ffmpeg-devel mailing list