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

Stefano Sabatini stefasab at gmail.com
Sun Mar 18 16:57:13 CET 2012


Fix crash with negative linesizes, fix trac ticket #1078.
---
 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){
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list