From 39aa116d95c5521cef63f9fd46712de427c3fdb3 Mon Sep 17 00:00:00 2001 From: Jonathan Protzenko Date: Tue, 31 May 2011 20:18:21 +0200 Subject: [PATCH] Bug 658351 - Add extra assertions to jsval.h to check for malformed JSBools r=mrbkap --- js/src/jsval.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/src/jsval.h b/js/src/jsval.h index f76f2970b7a..c871481df87 100644 --- a/js/src/jsval.h +++ b/js/src/jsval.h @@ -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; }