summaryrefslogtreecommitdiff
path: root/libavcodec/jpeglsenc.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-03-18 16:42:32 +0100
committerStefano Sabatini <stefasab@gmail.com>2012-03-18 21:19:09 +0100
commit0ca15aa066f1fad20853f5a560f13688d095ea81 (patch)
tree82c83aa67212d53b832bd02fe5efe74ba93e552c /libavcodec/jpeglsenc.c
parenta41340f8e85a13ec0b5a8a6bb93d09342adac047 (diff)
lavc/jpeglsenc: fix allocation in case of negative linesize, and add malloc check
Fix crash with negative linesizes, fix trac ticket #1078.
Diffstat (limited to 'libavcodec/jpeglsenc.c')
-rw-r--r--libavcodec/jpeglsenc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 62a2328a0a..aff1c6dd82 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){