Handle NaN value storing in Uint8Clamped typed arrays.

TEST=mjsunit/external-array
BUG=
R=dslomov@chromium.org

Review URL: https://codereview.chromium.org/667113002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24766 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
dusan.milosavljevic@imgtec.com 2014-10-21 11:10:13 +00:00
parent ac8b70cf2b
commit 0ffa82c3ac

View File

@ -4173,7 +4173,8 @@ typename Traits::ElementType FixedTypedArray<Traits>::from_double(
template<> inline
uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from_double(double value) {
if (value < 0) return 0;
// Handle NaNs and less than zero values which clamp to zero.
if (!(value > 0)) return 0;
if (value > 0xFF) return 0xFF;
return static_cast<uint8_t>(lrint(value));
}