mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 21:18:35 +00:00
Fixing bug 319296. This fixes a problem where we could end up in a situation where a nsIXPCScriptable helper would be used for a class info object when the helper is obviously written only for the class described by the class info. r=mrbkap@gmail.com, sr=brendan@mozilla.org
This commit is contained in:
parent
fa0ebe1dd4
commit
f80210c06e
@ -273,26 +273,37 @@ XPCWrappedNative::GetNewOrUsed(XPCCallContext& ccx,
|
||||
// It is possible that we will then end up forwarding this entire call
|
||||
// to this same function but with a different scope.
|
||||
|
||||
nsCOMPtr<nsIClassInfo> info(do_QueryInterface(identity));
|
||||
#ifdef XPC_IDISPATCH_SUPPORT
|
||||
// If this is an IDispatch wrapper and it didn't give us a class info
|
||||
// we'll provide a default one
|
||||
if(isIDispatch && !info)
|
||||
{
|
||||
info = already_AddRefed<nsIClassInfo>(XPCIDispatchClassInfo::GetSingleton());
|
||||
}
|
||||
#endif
|
||||
|
||||
// If we are making a wrapper for the nsIClassInfo interface then
|
||||
// We *don't* want to have it use the prototype meant for instances
|
||||
// of that class.
|
||||
JSBool isClassInfo = Interface->GetIID()->Equals(NS_GET_IID(nsIClassInfo));
|
||||
|
||||
nsCOMPtr<nsIClassInfo> info;
|
||||
|
||||
if(!isClassInfo)
|
||||
info = do_QueryInterface(identity);
|
||||
|
||||
#ifdef XPC_IDISPATCH_SUPPORT
|
||||
// If this is an IDispatch wrapper and it didn't give us a class info
|
||||
// we'll provide a default one
|
||||
if(isIDispatch && !info)
|
||||
{
|
||||
info = dont_AddRef(XPCIDispatchClassInfo::GetSingleton());
|
||||
}
|
||||
#endif
|
||||
|
||||
XPCNativeScriptableCreateInfo sciProto;
|
||||
XPCNativeScriptableCreateInfo sciWrapper;
|
||||
|
||||
if(NS_FAILED(GatherScriptableCreateInfo(identity,
|
||||
isClassInfo ? nsnull : info.get(),
|
||||
// Gather scriptable create info if we are wrapping something
|
||||
// other than an nsIClassInfo object. We need to not do this for
|
||||
// nsIClassInfo objects because often nsIClassInfo implementations
|
||||
// are also nsIXPCScriptable helper implmentations, but the helper
|
||||
// code is obviously intended for the implementation of the class
|
||||
// described by the nsIClassInfo, not for the class info object
|
||||
// itself.
|
||||
if(!isClassInfo &&
|
||||
NS_FAILED(GatherScriptableCreateInfo(identity, info.get(),
|
||||
&sciProto, &sciWrapper)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user