Bug 1028588 - Fix dangerous public destructors in js/xpconnect - r=bholley

This commit is contained in:
Benoit Jacob 2014-06-23 14:49:08 -04:00
Родитель 9a1a886bf7
Коммит 27fb6960a5
12 изменённых файлов: 77 добавлений и 34 удалений

Просмотреть файл

@ -46,7 +46,6 @@ class mozJSComponentLoader : public mozilla::ModuleLoader,
NS_DECL_NSIOBSERVER
mozJSComponentLoader();
virtual ~mozJSComponentLoader();
// ModuleLoader
const mozilla::Module* LoadModule(mozilla::FileLocation &aFile);
@ -59,6 +58,8 @@ class mozJSComponentLoader : public mozilla::ModuleLoader,
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
protected:
virtual ~mozJSComponentLoader();
static mozJSComponentLoader* sSelf;
nsresult ReallyInit();

Просмотреть файл

@ -385,6 +385,12 @@ public:
, mScriptLength(0)
{}
static void OffThreadCallback(void *aToken, void *aData);
/* Sends the "done" notification back. Main thread only. */
void SendObserverNotification();
private:
virtual ~ScriptPrecompiler()
{
if (mScriptBuf) {
@ -392,12 +398,6 @@ public:
}
}
static void OffThreadCallback(void *aToken, void *aData);
/* Sends the "done" notification back. Main thread only. */
void SendObserverNotification();
private:
nsRefPtr<nsIObserver> mObserver;
nsRefPtr<nsIPrincipal> mPrincipal;
nsRefPtr<nsIChannel> mChannel;

Просмотреть файл

@ -25,13 +25,14 @@ class mozJSSubScriptLoader : public mozIJSSubScriptLoader
{
public:
mozJSSubScriptLoader();
virtual ~mozJSSubScriptLoader();
// all the interface method declarations...
NS_DECL_ISUPPORTS
NS_DECL_MOZIJSSUBSCRIPTLOADER
private:
virtual ~mozJSSubScriptLoader();
nsresult ReadScript(nsIURI *uri, JSContext *cx, JSObject *target_obj,
const nsAString &charset, const char *uriStr,
nsIIOService *serv, nsIPrincipal *principal,

Просмотреть файл

@ -29,7 +29,6 @@ public:
{
SetWrapper(global);
}
virtual ~SandboxPrivate() { }
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(SandboxPrivate,
@ -49,7 +48,10 @@ public:
{
ClearWrapper();
}
private:
virtual ~SandboxPrivate() { }
nsCOMPtr<nsIPrincipal> mPrincipal;
};

Просмотреть файл

@ -47,9 +47,9 @@ public:
{
}
private:
virtual ~BackstagePass() { }
private:
nsCOMPtr<nsIPrincipal> mPrincipal;
JS::TenuredHeap<JSObject*> mGlobal;
};

Просмотреть файл

@ -69,9 +69,10 @@ public:
public:
nsXPCComponents_utils_Sandbox();
virtual ~nsXPCComponents_utils_Sandbox();
private:
virtual ~nsXPCComponents_utils_Sandbox();
static nsresult CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, HandleObject obj,
const CallArgs &args, bool *_retval);
@ -1767,7 +1768,6 @@ class ContextHolder : public nsIScriptObjectPrincipal
{
public:
ContextHolder(JSContext *aOuterCx, HandleObject aSandbox, nsIPrincipal *aPrincipal);
virtual ~ContextHolder();
JSContext * GetJSContext()
{
@ -1779,6 +1779,8 @@ public:
NS_DECL_ISUPPORTS
private:
virtual ~ContextHolder();
JSContext* mJSContext;
nsCOMPtr<nsIPrincipal> mPrincipal;
};

Просмотреть файл

@ -108,9 +108,10 @@ public:
public:
nsXPCComponents_Interfaces();
virtual ~nsXPCComponents_Interfaces();
private:
virtual ~nsXPCComponents_Interfaces();
nsCOMArray<nsIInterfaceInfo> mInterfaces;
};
@ -358,9 +359,10 @@ public:
public:
nsXPCComponents_InterfacesByID();
virtual ~nsXPCComponents_InterfacesByID();
private:
virtual ~nsXPCComponents_InterfacesByID();
nsCOMArray<nsIInterfaceInfo> mInterfaces;
};
@ -613,6 +615,8 @@ public:
public:
nsXPCComponents_Classes();
private:
virtual ~nsXPCComponents_Classes();
};
@ -852,6 +856,8 @@ public:
public:
nsXPCComponents_ClassesByID();
private:
virtual ~nsXPCComponents_ClassesByID();
};
@ -1113,6 +1119,8 @@ public:
public:
nsXPCComponents_Results();
private:
virtual ~nsXPCComponents_Results();
};
@ -1332,9 +1340,9 @@ public:
public:
nsXPCComponents_ID();
virtual ~nsXPCComponents_ID();
private:
virtual ~nsXPCComponents_ID();
static nsresult CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, HandleObject obj,
const CallArgs &args, bool *_retval);
@ -1549,9 +1557,9 @@ public:
public:
nsXPCComponents_Exception();
virtual ~nsXPCComponents_Exception();
private:
virtual ~nsXPCComponents_Exception();
static nsresult CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, HandleObject obj,
const CallArgs &args, bool *_retval);
@ -1935,9 +1943,9 @@ public:
nsXPCConstructor(nsIJSCID* aClassID,
nsIJSIID* aInterfaceID,
const char* aInitializer);
virtual ~nsXPCConstructor();
private:
virtual ~nsXPCConstructor();
nsresult CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, HandleObject obj,
const CallArgs &args, bool *_retval);
@ -2194,9 +2202,9 @@ public:
public:
nsXPCComponents_Constructor();
virtual ~nsXPCComponents_Constructor();
private:
virtual ~nsXPCComponents_Constructor();
static nsresult CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, HandleObject obj,
const CallArgs &args, bool *_retval);
@ -2507,9 +2515,9 @@ public:
public:
nsXPCComponents_Utils() { }
virtual ~nsXPCComponents_Utils() { }
private:
virtual ~nsXPCComponents_Utils() { }
nsCOMPtr<nsIXPCComponents_utils_Sandbox> mSandbox;
};
@ -3436,9 +3444,11 @@ class WrappedJSHolder : public nsISupports
{
NS_DECL_ISUPPORTS
WrappedJSHolder() {}
virtual ~WrappedJSHolder() {}
nsRefPtr<nsXPCWrappedJS> mWrappedJS;
private:
virtual ~WrappedJSHolder() {}
};
NS_IMPL_ISUPPORTS0(WrappedJSHolder);

Просмотреть файл

@ -204,6 +204,7 @@ nsJSID::NewID(const nsID& id)
class SharedScriptableHelperForJSIID MOZ_FINAL : public nsIXPCScriptable
{
~SharedScriptableHelperForJSIID() {}
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIXPCSCRIPTABLE

Просмотреть файл

@ -1174,6 +1174,9 @@ class WatchdogManager : public nsIObserver
// Register ourselves as an observer to get updates on the pref.
mozilla::Preferences::AddStrongObserver(this, "dom.use_watchdog");
}
protected:
virtual ~WatchdogManager()
{
// Shutting down the watchdog requires context-switching to the watchdog
@ -1183,6 +1186,8 @@ class WatchdogManager : public nsIObserver
mozilla::Preferences::RemoveObserver(this, "dom.use_watchdog");
}
public:
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData)
{
@ -1786,6 +1791,8 @@ JSMainRuntimeCompartmentsUserDistinguishedAmount()
class JSMainRuntimeTemporaryPeakReporter MOZ_FINAL : public nsIMemoryReporter
{
~JSMainRuntimeTemporaryPeakReporter() {}
public:
NS_DECL_ISUPPORTS
@ -2553,6 +2560,9 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
class JSMainRuntimeCompartmentsReporter MOZ_FINAL : public nsIMemoryReporter
{
~JSMainRuntimeCompartmentsReporter() {}
public:
NS_DECL_ISUPPORTS

Просмотреть файл

@ -13,6 +13,8 @@
class xpcJSWeakReference MOZ_FINAL : public xpcIJSWeakReference
{
~xpcJSWeakReference() {}
public:
xpcJSWeakReference();
nsresult Init(JSContext* cx, const JS::Value& object);

Просмотреть файл

@ -294,8 +294,6 @@ public:
// Called by module code on dll shutdown.
static void ReleaseXPConnectSingleton();
virtual ~nsXPConnect();
bool IsShuttingDown() const {return mShuttingDown;}
nsresult GetInfoForIID(const nsIID * aIID, nsIInterfaceInfo** info);
@ -318,6 +316,8 @@ public:
static void CheckForDebugMode(JSRuntime *rt);
protected:
virtual ~nsXPConnect();
nsXPConnect();
private:
@ -2278,13 +2278,13 @@ public:
const nsAString& aName,
nsIVariant** aResult);
virtual ~nsXPCWrappedJSClass();
static nsresult CheckForException(XPCCallContext & ccx,
const char * aPropertyName,
const char * anInterfaceName,
bool aForceReport);
private:
virtual ~nsXPCWrappedJSClass();
nsXPCWrappedJSClass(); // not implemented
nsXPCWrappedJSClass(JSContext* cx, REFNSIID aIID,
nsIInterfaceInfo* aInfo);
@ -2447,12 +2447,12 @@ public:
public:
static XPCJSObjectHolder* newHolder(JSObject* obj);
virtual ~XPCJSObjectHolder();
void TraceJS(JSTracer *trc);
static void GetTraceName(JSTracer* trc, char *buf, size_t bufsize);
private:
virtual ~XPCJSObjectHolder();
XPCJSObjectHolder(JSObject* obj);
XPCJSObjectHolder(); // not implemented
@ -2474,9 +2474,10 @@ public:
NS_DECL_NSIPROPERTY
xpcProperty(const char16_t* aName, uint32_t aNameLen, nsIVariant* aValue);
virtual ~xpcProperty() {}
private:
virtual ~xpcProperty() {}
nsString mName;
nsCOMPtr<nsIVariant> mValue;
};
@ -2675,7 +2676,6 @@ public:
nsJSID();
virtual ~nsJSID();
protected:
void Reset();
const nsID& GetInvalidIID() const;
@ -2687,6 +2687,14 @@ protected:
char* mName;
};
namespace mozilla {
template<>
struct HasDangerousPublicDestructor<nsJSID>
{
static const bool value = true;
};
}
// nsJSIID
class nsJSIID : public nsIJSIID,
@ -2706,9 +2714,10 @@ public:
nsJSIID(nsIInterfaceInfo* aInfo);
nsJSIID(); // not implemented
virtual ~nsJSIID();
private:
virtual ~nsJSIID();
nsCOMPtr<nsIInterfaceInfo> mInfo;
};
@ -2729,9 +2738,10 @@ public:
static already_AddRefed<nsJSCID> NewID(const char* str);
nsJSCID();
virtual ~nsJSCID();
private:
virtual ~nsJSCID();
void ResolveName();
private:
@ -2822,11 +2832,12 @@ public:
public:
void SystemIsBeingShutDown() { ClearMembers(); }
virtual ~nsXPCComponentsBase();
XPCWrappedNativeScope *GetScope() { return mScope; }
protected:
virtual ~nsXPCComponentsBase();
nsXPCComponentsBase(XPCWrappedNativeScope* aScope);
virtual void ClearMembers();
@ -2904,8 +2915,6 @@ class nsScriptError : public nsIScriptError {
public:
nsScriptError();
virtual ~nsScriptError();
// TODO - do something reasonable on getting null from these babies.
NS_DECL_THREADSAFE_ISUPPORTS
@ -2913,6 +2922,8 @@ public:
NS_DECL_NSISCRIPTERROR
private:
virtual ~nsScriptError();
nsString mMessage;
nsString mSourceName;
uint32_t mLineNumber;

Просмотреть файл

@ -23,6 +23,8 @@ class xpcTestObjectReadOnly MOZ_FINAL : public nsIXPCTestObjectReadOnly {
xpcTestObjectReadOnly();
private:
~xpcTestObjectReadOnly() {}
bool boolProperty;
int16_t shortProperty;
int32_t longProperty;
@ -37,9 +39,10 @@ class xpcTestObjectReadWrite MOZ_FINAL : public nsIXPCTestObjectReadWrite {
NS_DECL_NSIXPCTESTOBJECTREADWRITE
xpcTestObjectReadWrite();
~xpcTestObjectReadWrite();
private:
~xpcTestObjectReadWrite();
bool boolProperty;
int16_t shortProperty;
int32_t longProperty;