avcodec/mjpegdec: check for malloc failure of blocks[] and last_nnz[]
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 13 Sep 2013 21:22:44 +0000 (23:22 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 13 Sep 2013 21:25:16 +0000 (23:25 +0200)
Fixes null pointer dereference
Fixes Ticket2947

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mjpegdec.c

index cca6902..d08818f 100644 (file)
@@ -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));