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){