diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-11-15 10:15:24 +0100 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2014-05-31 20:05:18 -0400 |
commit | 2cbc8dfeddcbe00ef5f112162912bb49c1dd6623 (patch) | |
tree | 1c9d21c1619c0f28660e244c1551a1e08f5153f5 | |
parent | afab4c422b60e83419e10ee3dd4ba7001798b3db (diff) | |
download | ffmpeg-2cbc8dfeddcbe00ef5f112162912bb49c1dd6623.tar.gz |
h264: check buffer size before accessing it
Fixes invalid reads.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org
-rw-r--r-- | libavcodec/h264.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index ba8872cc5f..f021e59713 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3919,7 +3919,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ s->workaround_bugs |= FF_BUG_TRUNCATED; if(!(s->workaround_bugs & FF_BUG_TRUNCATED)){ - while(ptr[dst_length - 1] == 0 && dst_length > 0) + while(dst_length > 0 && ptr[dst_length - 1] == 0) dst_length--; } bit_length= !dst_length ? 0 : (8*dst_length - ff_h264_decode_rbsp_trailing(h, ptr + dst_length - 1)); |