Fixed a problem with the NS_GENERIC_FACTORY_CONSTRUCTOR_INIT() macro.
If the Init() routine happens to perform a balanced AddRef/Release, the instance will be prematurely destroyed when Release() is called. The change is to do the AddRef() before calling the initialization routine to stabilize the instance's ref-count. r: dp, putterman git-svn-id: svn://10.0.0.236/trunk@53608 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
474d46c354
commit
2b188ce191
@ -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; \
|
||||
|
||||
@ -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; \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user