[FFmpeg-cvslog] lavc/jpeglsenc: fix allocation in case of negative linesize, and add malloc check

Stefano Sabatini git at videolan.org
Sun Mar 18 21:29:10 CET 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Sun Mar 18 16:42:32 2012 +0100| [0ca15aa066f1fad20853f5a560f13688d095ea81] | committer: Stefano Sabatini

lavc/jpeglsenc: fix allocation in case of negative linesize, and add malloc check

Fix crash with negative linesizes, fix trac ticket #1078.

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

 libavcodec/jpeglsenc.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 62a2328..aff1c6d 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -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){



More information about the ffmpeg-cvslog mailing list