aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-29 14:15:29 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-11-02 02:20:10 +0100
commitbde9e859b3c7ebb0f76437dd6457a41ac8904740 (patch)
treeef3f3c12f9de01faa7300d8549237a4718e255a1
parent85cac770bdb0ed871ce5715452f416d16d36d7e8 (diff)
downloadffmpeg-bde9e859b3c7ebb0f76437dd6457a41ac8904740.tar.gz
avcodec/utils: Align dimensions by at least their chroma sub-sampling factors.
Fixes: out of array accesses Fixes: asan_heap-oob_112c6b3_13_012.avi Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit df74811cd53e45fcbbd3b77a1c42416816687c5c) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/utils.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a6de45cdc7..8e421e7073 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -196,6 +196,12 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int i;
int w_align = 1;
int h_align = 1;
+ AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
+
+ if (desc) {
+ w_align = 1 << desc->log2_chroma_w;
+ h_align = 1 << desc->log2_chroma_h;
+ }
switch (s->pix_fmt) {
case AV_PIX_FMT_YUV420P:
@@ -310,8 +316,6 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
}
break;
default:
- w_align = 1;
- h_align = 1;
break;
}