lavc/jpeglsenc: fix allocation in case of negative linesize, and add malloc check
authorStefano Sabatini <stefasab@gmail.com>
Sun, 18 Mar 2012 15:42:32 +0000 (16:42 +0100)
committerStefano Sabatini <stefasab@gmail.com>
Sun, 18 Mar 2012 20:19:09 +0000 (21:19 +0100)
Fix crash with negative linesizes, fix trac ticket #1078.

libavcodec/jpeglsenc.c

index 62a2328..aff1c6d 100644 (file)
@@ -295,7 +295,9 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
 
     ls_store_lse(state, &pb);
 
-    zero = av_mallocz(p->linesize[0]);
+    zero = av_mallocz(FFABS(p->linesize[0]));
+    if (!zero)
+        return AVERROR(ENOMEM);
     last = zero;
     cur = p->data[0];
     if(avctx->pix_fmt == PIX_FMT_GRAY8){