Bug 683802 - Add jsval to the XPTCMiniVariant union for type safety. r=mrbkap

This commit is contained in:
Bobby Holley 2011-09-23 14:50:28 -07:00
parent c0aa2b6439
commit 7386fc9507
2 changed files with 9 additions and 6 deletions

View File

@ -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();
}

View File

@ -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;
};