diff --git a/mozilla/xpcom/components/nsIGenericFactory.h b/mozilla/xpcom/components/nsIGenericFactory.h index 8aa8012cdfc..79e6bf370f2 100644 --- a/mozilla/xpcom/components/nsIGenericFactory.h +++ b/mozilla/xpcom/components/nsIGenericFactory.h @@ -156,14 +156,12 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) if (NULL == inst) { \ rv = NS_ERROR_OUT_OF_MEMORY; \ return rv; \ - } \ - rv = inst->_InitMethod(); \ - if(NS_FAILED(rv)) { \ - NS_DELETEXPCOM(inst); \ - return rv; \ } \ NS_ADDREF(inst); \ - rv = inst->QueryInterface(aIID, aResult); \ + rv = inst->_InitMethod(); \ + if(NS_SUCCEEDED(rv)) { \ + rv = inst->QueryInterface(aIID, aResult); \ + } \ NS_RELEASE(inst); \ \ return rv; \ diff --git a/mozilla/xpcom/glue/nsIGenericFactory.h b/mozilla/xpcom/glue/nsIGenericFactory.h index 8aa8012cdfc..79e6bf370f2 100644 --- a/mozilla/xpcom/glue/nsIGenericFactory.h +++ b/mozilla/xpcom/glue/nsIGenericFactory.h @@ -156,14 +156,12 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) if (NULL == inst) { \ rv = NS_ERROR_OUT_OF_MEMORY; \ return rv; \ - } \ - rv = inst->_InitMethod(); \ - if(NS_FAILED(rv)) { \ - NS_DELETEXPCOM(inst); \ - return rv; \ } \ NS_ADDREF(inst); \ - rv = inst->QueryInterface(aIID, aResult); \ + rv = inst->_InitMethod(); \ + if(NS_SUCCEEDED(rv)) { \ + rv = inst->QueryInterface(aIID, aResult); \ + } \ NS_RELEASE(inst); \ \ return rv; \