Commit b4366518 authored by Ted Meyer's avatar Ted Meyer Committed by Commit Bot

Fix clusterfuzz base::Value(NaN) check

check all floats and doubles to make sure they are finite - report 'NaN'
otherwise.

Bug: 1027412
Change-Id: I3c424f82e66434e89fc7268d65a980a6bd86fd1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1935887
Commit-Queue: Ted Meyer <tmathmeyer@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719322}
parent ae1feb5a
......@@ -34,11 +34,24 @@ struct MediaLogPropertyTypeConverter {};
_VALUE_CONSTRUCTOR_TYPE(std::string, const std::string&);
_VALUE_CONSTRUCTOR_TYPE(bool, bool);
_VALUE_CONSTRUCTOR_TYPE(int, int);
_VALUE_CONSTRUCTOR_TYPE(double, double);
_VALUE_CONSTRUCTOR_TYPE(float, float);
#undef _VALUE_CONSTRUCTOR_TYPE
// Can't send non-finite double values to a base::Value.
template <>
struct MediaLogPropertyTypeConverter<double> {
static base::Value Convert(double value) {
return std::isfinite(value) ? base::Value(value) : base::Value("unknown");
}
};
// Just upcast this to get the NaN check.
template <>
struct MediaLogPropertyTypeConverter<float> {
static base::Value Convert(float value) {
return MediaLogPropertyTypeConverter<double>::Convert(value);
}
};
/* Support serializing for a selection of types */
// support 64 bit ints, this is a weird workaround for the base::Value
// int type only being 32 bit, as specified in the base/values.h header comment.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment