cafdec: fix overflow checking in read_header()

Several compilers such as clang/icc/pathscale will optimize the check
pos + size < pos (assuming size > 0) into false, since signed integer
overflow is undefined behavior in C.  This breaks overflow checking.
Use a safe precondition check instead.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Xi Wang 2013-01-20 15:26:12 -05:00 committed by Michael Niedermayer
parent 3317414fc1
commit 64b7e7dcaf

View File

@ -300,7 +300,7 @@ static int read_header(AVFormatContext *s)
}
if (size > 0) {
if (pos + size < pos)
if (pos > INT64_MAX - size)
return AVERROR_INVALIDDATA;
avio_skip(pb, FFMAX(0, pos + size - avio_tell(pb)));
}