summaryrefslogtreecommitdiff
path: root/libavcodec/msrle.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-02-16 23:08:52 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-16 23:20:57 +0100
commitc919e1ca2ecfc47d796382973ba0e48b8f6f92a2 (patch)
tree856005c0f6d7935b62ead86642b91e696d43474b /libavcodec/msrle.c
parent2218fbe05e6dceb9db126c42f52e2a7fe4c05f5b (diff)
avcodec/msrle: use av_image_get_linesize() to calculate the linesize
Fixes out of array access Fixes: 14a74a0a2dc67ede543f0e35d834fbbe-asan_heap-oob_49572c_556_cov_215466444_44_001_engine_room.mov Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/msrle.c')
-rw-r--r--libavcodec/msrle.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
index 7ae4b08ba6..ad04ce8984 100644
--- a/libavcodec/msrle.c
+++ b/libavcodec/msrle.c
@@ -35,6 +35,7 @@
#include "avcodec.h"
#include "internal.h"
#include "msrledec.h"
+#include "libavutil/imgutils.h"
typedef struct MsrleContext {
AVCodecContext *avctx;
@@ -110,7 +111,7 @@ static int msrle_decode_frame(AVCodecContext *avctx,
/* FIXME how to correctly detect RLE ??? */
if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
- int linesize = (avctx->width * avctx->bits_per_coded_sample + 7) / 8;
+ int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
uint8_t *ptr = s->frame->data[0];
uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
int i, j;