Bug 897676 - Null out |si| if we end up using that of the proto in WrapNewGlobal. r=mrbkap

This commit is contained in:
Bobby Holley 2013-07-30 08:53:56 -07:00
parent dbea38ef61
commit dc8ec482b2

View File

@ -360,7 +360,13 @@ XPCWrappedNative::WrapNewGlobal(xpcObjectHelper &nativeHelper,
XPCNativeScriptableInfo* siProto = proto->GetScriptableInfo();
if (siProto && siProto->GetCallback() == sciWrapper.GetCallback()) {
wrapper->mScriptableInfo = siProto;
// XPCNativeScriptableShared instances live in a map, and are
// GCed, but XPCNativeScriptableInfo is per-instance and must be
// manually managed. If we're switching over to that of the proto, we
// need to destroy the one we've allocated, and also null out the
// AutoMarkingPtr, so that it doesn't try to mark garbage data.
delete si;
si = nullptr;
} else {
wrapper->mScriptableInfo = si;
}