Bug 1021151 - avoid memory leak in NS_GENERIC_AGGREGATED_CONSTRUCTOR_INIT, use nsAutoPtr instead of naked ptr. r=Ehsan

MozReview-Commit-ID: 6iU7ikbgjEn
This commit is contained in:
Bogdan Postelnicu 2016-02-23 14:12:22 +02:00
parent 1a29056508
commit 50bbc8e987

View File

@ -295,16 +295,13 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
if (NS_WARN_IF(aOuter && !aIID.Equals(NS_GET_IID(nsISupports)))) \
return NS_ERROR_INVALID_ARG; \
\
_InstanceClass* inst = new _InstanceClass(aOuter); \
RefPtr<_InstanceClass> inst = new _InstanceClass(aOuter); \
if (!inst) { \
return NS_ERROR_OUT_OF_MEMORY; \
} \
\
nsISupports* inner = inst->InnerObject(); \
nsresult rv = inner->QueryInterface(aIID, aResult); \
if (NS_FAILED(rv)) { \
delete inst; \
} \
\
return rv; \
} \
@ -318,7 +315,7 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
if (NS_WARN_IF(aOuter && !aIID.Equals(NS_GET_IID(nsISupports)))) \
return NS_ERROR_INVALID_ARG; \
\
_InstanceClass* inst = new _InstanceClass(aOuter); \
RefPtr<_InstanceClass> inst = new _InstanceClass(aOuter); \
if (!inst) { \
return NS_ERROR_OUT_OF_MEMORY; \
} \