From 3ed1410633f32b71704be9c3ae10d8e15c3d4471 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Sat, 8 Apr 2006 01:14:45 +0000 Subject: [PATCH] Root across calls to JS_SetElement and JS_SetProperty. b=331667 r=jst,dbradley sr=brendan a=jst git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@193898 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/xpconnect/src/XPCDispConvert.cpp | 8 +++++--- mozilla/js/src/xpconnect/src/XPCDispTearOff.cpp | 1 + mozilla/js/src/xpconnect/src/xpcconvert.cpp | 3 ++- mozilla/js/src/xpconnect/src/xpcprivate.h | 9 +++++++-- mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp | 3 ++- mozilla/js/src/xpconnect/src/xpcwrappednative.cpp | 3 ++- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/mozilla/js/src/xpconnect/src/XPCDispConvert.cpp b/mozilla/js/src/xpconnect/src/XPCDispConvert.cpp index 2a6f9c65169..e75b245e8a5 100644 --- a/mozilla/js/src/xpconnect/src/XPCDispConvert.cpp +++ b/mozilla/js/src/xpconnect/src/XPCDispConvert.cpp @@ -390,7 +390,8 @@ JSBool XPCDispConvert::COMArrayToJSArray(XPCCallContext& ccx, err = NS_ERROR_OUT_OF_MEMORY; return JS_FALSE; } - // Devine the type of our array + AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(array)); + // Divine the type of our array VARTYPE vartype; if((src.vt & VT_ARRAY) != 0) { @@ -401,10 +402,11 @@ JSBool XPCDispConvert::COMArrayToJSArray(XPCCallContext& ccx, if(FAILED(SafeArrayGetVartype(src.parray, &vartype))) return JS_FALSE; } - jsval val; + jsval val = JSVAL_NULL; + AUTO_MARK_JSVAL(ccx, &val); for(long index = lbound; index <= ubound; ++index) { - // Devine the type of our array + // Divine the type of our array _variant_t var; var.vt = vartype; if(FAILED(SafeArrayGetElement(src.parray, &index, &var.byref))) diff --git a/mozilla/js/src/xpconnect/src/XPCDispTearOff.cpp b/mozilla/js/src/xpconnect/src/XPCDispTearOff.cpp index c0cdcb7ae2e..b4dbebb2553 100644 --- a/mozilla/js/src/xpconnect/src/XPCDispTearOff.cpp +++ b/mozilla/js/src/xpconnect/src/XPCDispTearOff.cpp @@ -302,6 +302,7 @@ STDMETHODIMP XPCDispatchTearOff::Invoke(DISPID dispIdMember, REFIID riid, msg += name; return Error(E_FAIL, msg.get()); } + AUTO_MARK_JSVAL(ccx, &val); obj = GetJSObject(); if(!obj) return Error(E_FAIL, "The JS wrapper did not return a JS object"); diff --git a/mozilla/js/src/xpconnect/src/xpcconvert.cpp b/mozilla/js/src/xpconnect/src/xpcconvert.cpp index 4e110a021b0..74f72c54b95 100644 --- a/mozilla/js/src/xpconnect/src/xpcconvert.cpp +++ b/mozilla/js/src/xpconnect/src/xpcconvert.cpp @@ -1623,7 +1623,8 @@ XPCConvert::NativeArray2JS(XPCCallContext& ccx, *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE; JSUint32 i; - jsval current; + jsval current = JSVAL_NULL; + AUTO_MARK_JSVAL(ccx, ¤t); #define POPULATE(_t) \ PR_BEGIN_MACRO \ diff --git a/mozilla/js/src/xpconnect/src/xpcprivate.h b/mozilla/js/src/xpconnect/src/xpcprivate.h index ed35e5033d9..f9db83ff27a 100644 --- a/mozilla/js/src/xpconnect/src/xpcprivate.h +++ b/mozilla/js/src/xpconnect/src/xpcprivate.h @@ -3427,8 +3427,13 @@ DEFINE_AUTO_MARKING_ARRAY_PTR_TYPE(AutoMarkingNativeInterfacePtrArrayPtr, // these and bind them to rooted things so immediately that this just is not // needed. -#define AUTO_MARK_JSVAL(ccx, val) \ - XPCMarkableJSVal _val(val); AutoMarkingJSVal _automarker(ccx, &_val) +#define AUTO_MARK_JSVAL_HELPER2(tok, line) tok##line +#define AUTO_MARK_JSVAL_HELPER(tok, line) AUTO_MARK_JSVAL_HELPER2(tok, line) + +#define AUTO_MARK_JSVAL(ccx, val) \ + XPCMarkableJSVal AUTO_MARK_JSVAL_HELPER(_val_,__LINE__)(val); \ + AutoMarkingJSVal AUTO_MARK_JSVAL_HELPER(_automarker_,__LINE__) \ + (ccx, &AUTO_MARK_JSVAL_HELPER(_val_,__LINE__)) #ifdef XPC_USE_SECURITY_CHECKED_COMPONENT /***************************************************************************/ diff --git a/mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp b/mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp index 7b87477ffd9..f2c1754e19b 100644 --- a/mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp +++ b/mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp @@ -1189,7 +1189,8 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex, nsXPTType datum_type; JSUint32 array_count; PRBool isArray = type.IsArray(); - jsval val; + jsval val = JSVAL_NULL; + AUTO_MARK_JSVAL(ccx, &val); PRBool isSizedString = isArray ? JS_FALSE : type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS || diff --git a/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp b/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp index 6fe0ae78382..3e531346ed8 100644 --- a/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp +++ b/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp @@ -2176,7 +2176,8 @@ XPCWrappedNative::CallMethod(XPCCallContext& ccx, const nsXPTType& type = paramInfo.GetType(); nsXPTCVariant* dp = &dispatchParams[i]; - jsval v; + jsval v = JSVAL_NULL; + AUTO_MARK_JSVAL(ccx, &v); JSUint32 array_count; nsXPTType datum_type; PRBool isArray = type.IsArray();