Open Bug 998092 Opened 6 years ago Updated 1 year ago

do_QueryObject abuse in PeerConnectionImpl.cpp


(Core :: DOM: Core & HTML, defect)

Not set




(Reporter: neil, Unassigned)



The code

nsRefPtr<nsSupportsWeakReference> tmp2 = do_QueryObject(tmp);

which appears in PeerConnectionImpl.cpp is an abuse of do_QueryObject, since nsSupportsWeakReference does not have an IID, so what happens is that tmp gets reinterpreted as an nsSupportsWeakReference*.

:bz suggested that the quick fix is to use static_cast<PeerConnectionObserver>(tmp.get()) instead.

An alternative would be to change the code generation to add an IID to PeerConnectionObserver so that you could write nsRefPtr<PeerConnectionObserver> pco = do_QueryReferent(mPCObserver); directly and avoid the kludge that is do_QueryObjectReferent.

Had it been possible to use an XPIDL interface in the first place then nsCOMPtr<nsIPeerConnectionObserver> pco = do_QueryReferent(mPCObserver); would also have sufficed.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.