From 0ffa82c3acd0e03fb217650cb24739029e1ce724 Mon Sep 17 00:00:00 2001 From: "dusan.milosavljevic@imgtec.com" Date: Tue, 21 Oct 2014 11:10:13 +0000 Subject: [PATCH] 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 --- src/objects-inl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/objects-inl.h b/src/objects-inl.h index 55f5c7f86f..4e964f8231 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -4173,7 +4173,8 @@ typename Traits::ElementType FixedTypedArray::from_double( template<> inline uint8_t FixedTypedArray::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(lrint(value)); }