diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-23 04:11:22 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-23 04:11:22 +0000 |
commit | eaa9771c78a314a309a9461b548910cf701ef5fa (patch) | |
tree | 5e3f2013bc65592fcf0aa89e7144b38c73a50737 /base | |
parent | 2f0a6476e26ebd0adc4e33308597895edafd70b1 (diff) | |
download | chromium_src-eaa9771c78a314a309a9461b548910cf701ef5fa.zip chromium_src-eaa9771c78a314a309a9461b548910cf701ef5fa.tar.gz chromium_src-eaa9771c78a314a309a9461b548910cf701ef5fa.tar.bz2 |
base: Map non-finite double Values to 0.0.
NaN and positive/negative infinity can't be represented in
JSON. I previously added a DCHECK(), but think it also
makes sense to do something with the values in release
builds so they can't leave profiles unreadable.
BUG=chromium-os:73856
TEST=none
Review URL: http://codereview.chromium.org/7708008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97816 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/values.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/base/values.cc b/base/values.cc index aba0715..191995c 100644 --- a/base/values.cc +++ b/base/values.cc @@ -162,8 +162,11 @@ FundamentalValue::FundamentalValue(int in_value) FundamentalValue::FundamentalValue(double in_value) : Value(TYPE_DOUBLE), double_value_(in_value) { - // JSON doesn't support NaN or positive or negative infinity. - DCHECK(IsFinite(in_value)); + if (!IsFinite(double_value_)) { + NOTREACHED() << "Non-finite (i.e. NaN or positive/negative infinity) " + << "values cannot be represented in JSON"; + double_value_ = 0.0; + } } FundamentalValue::~FundamentalValue() { |