[FFmpeg-cvslog] avcodec/mjpegdec: check for malloc failure of blocks[] and last_nnz[]

Michael Niedermayer git at videolan.org
Fri Sep 13 23:30:21 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Sep 13 23:22:44 2013 +0200| [6c07e41f43026eb65b6a4afc3119d6666781c211] | committer: Michael Niedermayer

avcodec/mjpegdec: check for malloc failure of blocks[] and last_nnz[]

Fixes null pointer dereference
Fixes Ticket2947

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6c07e41f43026eb65b6a4afc3119d6666781c211
---

 libavcodec/mjpegdec.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index cca6902..d08818f 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -507,6 +507,8 @@ unk_pixfmt:
             av_freep(&s->last_nnz[i]);
             s->blocks[i]       = av_malloc(size * sizeof(**s->blocks));
             s->last_nnz[i]     = av_mallocz(size * sizeof(**s->last_nnz));
+            if (!s->blocks[i] || !s->last_nnz[i])
+                return AVERROR(ENOMEM);
             s->block_stride[i] = bw * s->h_count[i];
         }
         memset(s->coefs_finished, 0, sizeof(s->coefs_finished));



More information about the ffmpeg-cvslog mailing list