diff --git a/xpcom/glue/nsCOMPtr.h b/xpcom/glue/nsCOMPtr.h index 85672beea032..b76429a7ecf1 100644 --- a/xpcom/glue/nsCOMPtr.h +++ b/xpcom/glue/nsCOMPtr.h @@ -767,15 +767,17 @@ class nsCOMPtr MOZ_FINAL return temp; } + template void - forget( T** rhs NS_OUTPARAM ) + forget( I** rhs NS_OUTPARAM ) // Set the target of rhs to the value of mRawPtr and null out mRawPtr. // Useful to avoid unnecessary AddRef/Release pairs with "out" - // parameters. + // parameters where rhs bay be a T** or an I** where I is a base class + // of T. { NS_ASSERTION(rhs, "Null pointer passed to forget!"); - *rhs = 0; - swap(*rhs); + *rhs = get(); + mRawPtr = 0; } T*