diff --git a/js/src/xpconnect/src/xpcwrappednative.cpp b/js/src/xpconnect/src/xpcwrappednative.cpp index 6d99a5d6cff3..14754702eae8 100644 --- a/js/src/xpconnect/src/xpcwrappednative.cpp +++ b/js/src/xpconnect/src/xpcwrappednative.cpp @@ -2848,12 +2848,9 @@ CallMethodHelper::ConvertIndependentParam(uint8 i) // indirectly, regardless of in/out-ness. if(type_tag == nsXPTType::T_JSVAL) { - // Assign the value - JS_STATIC_ASSERT(sizeof(jsval) <= sizeof(dp->val)); - jsval *rootp = (jsval *)&dp->val; - dp->ptr = rootp; - *rootp = JSVAL_VOID; - if(!JS_AddValueRoot(mCallContext, rootp)) + // Root the value. + dp->val.j = JSVAL_VOID; + if (!JS_AddValueRoot(mCallContext, &dp->val.j)) return JS_FALSE; dp->SetValIsJSRoot(); } diff --git a/xpcom/reflect/xptcall/public/xptcall.h b/xpcom/reflect/xptcall/public/xptcall.h index f58b5ec93540..1ac59195823e 100644 --- a/xpcom/reflect/xptcall/public/xptcall.h +++ b/xpcom/reflect/xptcall/public/xptcall.h @@ -52,6 +52,7 @@ #include "nsISupports.h" #include "xpt_struct.h" #include "xptinfo.h" +#include "jsapi.h" struct nsXPTCMiniVariant { @@ -73,6 +74,11 @@ struct nsXPTCMiniVariant char c; PRUnichar wc; void* p; + + // Types below here are unknown to the assembly implementations, and + // therefore _must_ be passed with indirect semantics. We put them in + // the union here for type safety, so that we can avoid void* tricks. + jsval j; } val; };