mkvparser:Parse: s/FLT_MIN/-FLT_MAX/
FLT_MIN is the smallest finite value (numeric_limits::min()) -FLT_MAX is the correct for the most negative (numeric_limits::lowest()) http://en.cppreference.com/w/cpp/types/numeric_limits BUG=b/36255773 BUG=webm:1381 Change-Id: Iaaff611acffc3df28fef12af81ac5299791f0148
This commit is contained in:
parent
35a3c88728
commit
2cef4d51a2
@ -4992,14 +4992,14 @@ bool PrimaryChromaticity::Parse(IMkvReader* reader, long long read_pos,
|
|||||||
const long long parse_status =
|
const long long parse_status =
|
||||||
UnserializeFloat(reader, read_pos, value_size, parser_value);
|
UnserializeFloat(reader, read_pos, value_size, parser_value);
|
||||||
|
|
||||||
if (parse_status < 0 || parser_value < FLT_MIN || parser_value > FLT_MAX)
|
// Valid range is [0, 1]. Make sure the double is representable as a float
|
||||||
|
// before casting.
|
||||||
|
if (parse_status < 0 || parser_value < 0.0 || parser_value > 1.0 ||
|
||||||
|
(parser_value > 0.0 && parser_value < FLT_MIN))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*value = static_cast<float>(parser_value);
|
*value = static_cast<float>(parser_value);
|
||||||
|
|
||||||
if (*value < 0.0 || *value > 1.0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5230,7 +5230,9 @@ bool Projection::Parse(IMkvReader* reader, long long start, long long size,
|
|||||||
double value = 0;
|
double value = 0;
|
||||||
const long long value_parse_status =
|
const long long value_parse_status =
|
||||||
UnserializeFloat(reader, read_pos, child_size, value);
|
UnserializeFloat(reader, read_pos, child_size, value);
|
||||||
if (value_parse_status < 0 || value < FLT_MIN || value > FLT_MAX) {
|
// Make sure value is representable as a float before casting.
|
||||||
|
if (value_parse_status < 0 || value < -FLT_MAX || value > FLT_MAX ||
|
||||||
|
(value > 0.0 && value < FLT_MIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user