Bug 1411977 - Part 5: Don't pass a pointer to a temporary to NotifyDataChannel_m. r=drno

MozReview-Commit-ID: 3ydeM9U1P4b

--HG--
extra : rebase_source : aad2510f6179d5cc3218b0b352540072a9dd2561
This commit is contained in:
Byron Campen [:bwc] 2018-01-25 10:04:55 -06:00
parent 83c9be0a4e
commit be3a417b19

View File

@ -1418,18 +1418,12 @@ PeerConnectionImpl::NotifyDataChannel(already_AddRefed<DataChannel> aChannel)
{
PC_AUTO_ENTER_API_CALL_NO_CHECK();
// XXXkhuey this is completely fucked up. We can't use RefPtr<DataChannel>
// here because DataChannel's AddRef/Release are non-virtual and not visible
// if !MOZILLA_INTERNAL_API, but this function leaks the DataChannel if
// !MOZILLA_INTERNAL_API because it never transfers the ref to
// NS_NewDOMDataChannel.
DataChannel* channel = aChannel.take();
RefPtr<DataChannel> channel(aChannel);
MOZ_ASSERT(channel);
CSFLogDebug(LOGTAG, "%s: channel: %p", __FUNCTION__, channel);
CSFLogDebug(LOGTAG, "%s: channel: %p", __FUNCTION__, channel.get());
nsCOMPtr<nsIDOMDataChannel> domchannel;
nsresult rv = NS_NewDOMDataChannel(already_AddRefed<DataChannel>(channel),
nsresult rv = NS_NewDOMDataChannel(channel.forget(),
mWindow, getter_AddRefs(domchannel));
NS_ENSURE_SUCCESS_VOID(rv);
@ -1442,7 +1436,7 @@ PeerConnectionImpl::NotifyDataChannel(already_AddRefed<DataChannel> aChannel)
RUN_ON_THREAD(mThread,
WrapRunnableNM(NotifyDataChannel_m,
domchannel.get(),
domchannel.forget(),
pco),
NS_DISPATCH_NORMAL);
}