diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-10-29 14:15:29 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-11-01 15:40:38 +0100 |
commit | 16a4aef34574549316ba1a96a26edd1c9a4fb1e3 (patch) | |
tree | e6f3a5759cff0de0d16ced759ef2569792c73c83 | |
parent | 6352153811161f859433299a811d34cdb51afbd7 (diff) | |
download | ffmpeg-16a4aef34574549316ba1a96a26edd1c9a4fb1e3.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.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 8b6f942fc4..8d24f0bed9 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -281,6 +281,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: @@ -407,8 +413,6 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, } break; default: - w_align = 1; - h_align = 1; break; } |