fix memory leaks in vcard and calendar factories r=rhp

This commit is contained in:
bienvenu%netscape.com 1999-10-22 20:32:02 +00:00
parent 36175be02d
commit c4ef9a290b
2 changed files with 4 additions and 8 deletions

View File

@ -118,7 +118,7 @@ nsCalendarFactory::CreateInstance(nsISupports *aOuter,
*aResult = NULL;
nsISupports *inst = nsnull;
nsCOMPtr <nsIMimeContentTypeHandler> inst;
// ClassID check happens here
// Whenever you add a new class that supports an interface, plug it in here!!!
@ -126,7 +126,7 @@ nsCalendarFactory::CreateInstance(nsISupports *aOuter,
// do they want a mime emitter interface ?
if (mClassID.Equals(kMimeContentTypeHandlerCID))
{
res = NS_NewMimeContentTypeHandler((nsIMimeContentTypeHandler **) &inst);
res = NS_NewMimeContentTypeHandler(getter_AddRefs(inst));
if (NS_FAILED(res)) // was there a problem creating the object ?
return res;
}
@ -137,8 +137,6 @@ nsCalendarFactory::CreateInstance(nsISupports *aOuter,
// so we now have the class that supports the desired interface...we need to turn around and
// query for our desired interface.....
res = inst->QueryInterface(aIID, aResult);
if (res != NS_OK) // if the query interface failed for some reason, then the object did not get ref counted...delete it.
delete inst;
}
else
res = NS_ERROR_OUT_OF_MEMORY;

View File

@ -118,7 +118,7 @@ nsVCardFactory::CreateInstance(nsISupports *aOuter,
*aResult = NULL;
nsISupports *inst = nsnull;
nsCOMPtr <nsIMimeContentTypeHandler> inst;
// ClassID check happens here
// Whenever you add a new class that supports an interface, plug it in here!!!
@ -126,7 +126,7 @@ nsVCardFactory::CreateInstance(nsISupports *aOuter,
// do they want a mime emitter interface ?
if (mClassID.Equals(kMimeContentTypeHandlerCID))
{
res = NS_NewMimeContentTypeHandler((nsIMimeContentTypeHandler **) &inst);
res = NS_NewMimeContentTypeHandler(getter_AddRefs(inst));
if (NS_FAILED(res)) // was there a problem creating the object ?
return res;
}
@ -137,8 +137,6 @@ nsVCardFactory::CreateInstance(nsISupports *aOuter,
// so we now have the class that supports the desired interface...we need to turn around and
// query for our desired interface.....
res = inst->QueryInterface(aIID, aResult);
if (res != NS_OK) // if the query interface failed for some reason, then the object did not get ref counted...delete it.
delete inst;
}
else
res = NS_ERROR_OUT_OF_MEMORY;