Bug 658351 - Add extra assertions to jsval.h to check for malformed JSBools r=mrbkap

This commit is contained in:
Jonathan Protzenko 2011-05-31 20:18:21 +02:00
parent f8876b89e0
commit 39aa116d95

View File

@ -462,6 +462,10 @@ static JS_ALWAYS_INLINE jsval_layout
BOOLEAN_TO_JSVAL_IMPL(JSBool b)
{
jsval_layout l;
// Happens if XPConnect hands out an illegal value (constructed from C++ through a PRBool, for
// instance).
JS_ASSERT(b == JS_TRUE || b == JS_FALSE);
l.s.tag = JSVAL_TAG_BOOLEAN;
l.s.payload.boo = b;
return l;
@ -654,6 +658,10 @@ static JS_ALWAYS_INLINE jsval_layout
BOOLEAN_TO_JSVAL_IMPL(JSBool b)
{
jsval_layout l;
// Happens if XPConnect hands out an illegal value (constructed from C++ through a PRBool, for
// instance).
JS_ASSERT(b == JS_TRUE || b == JS_FALSE);
l.asBits = ((uint64)(uint32)b) | JSVAL_SHIFTED_TAG_BOOLEAN;
return l;
}