fix C string leak, bug=18699, r=shaver

This commit is contained in:
beard%netscape.com 1999-11-19 02:14:23 +00:00
parent 113be4aaab
commit 252e9c7159
2 changed files with 8 additions and 10 deletions

View File

@ -1474,7 +1474,7 @@ nsComponentManagerImpl::RegisterComponentWithType(const nsCID &aClass,
const char *aType)
{
return RegisterComponentCommon(aClass, aClassName, aProgID,
nsCRT::strdup(aLocation),
aLocation,
aReplace, aPersist,
aType);
}
@ -1490,8 +1490,8 @@ nsComponentManagerImpl::RegisterComponentSpec(const nsCID &aClass,
PRBool aReplace,
PRBool aPersist)
{
char *registryName;
nsresult rv = RegistryLocationForSpec(aLibrarySpec, &registryName);
nsXPIDLCString registryName;
nsresult rv = RegistryLocationForSpec(aLibrarySpec, getter_Copies(registryName));
if (NS_FAILED(rv))
return rv;
@ -1499,7 +1499,6 @@ nsComponentManagerImpl::RegisterComponentSpec(const nsCID &aClass,
registryName,
aReplace, aPersist,
nativeComponentType);
nsAllocator::Free(registryName);
return rv;
}
@ -1518,8 +1517,8 @@ nsComponentManagerImpl::RegisterComponentLib(const nsCID &aClass,
PRBool aReplace,
PRBool aPersist)
{
char *registryName;
nsresult rv = RegistryNameForLib(aDllName, &registryName);
nsXPIDLCString registryName;
nsresult rv = RegistryNameForLib(aDllName, getter_Copies(registryName));
if (NS_FAILED(rv))
return rv;
return RegisterComponentCommon(aClass, aClassName, aProgID, registryName,
@ -1537,7 +1536,7 @@ nsresult
nsComponentManagerImpl::RegisterComponentCommon(const nsCID &aClass,
const char *aClassName,
const char *aProgID,
char *aRegistryName,
const char *aRegistryName,
PRBool aReplace,
PRBool aPersist,
const char *aType)
@ -1639,8 +1638,6 @@ nsComponentManagerImpl::RegisterComponentCommon(const nsCID &aClass,
out:
if (NS_FAILED(rv)) {
if (aRegistryName)
nsAllocator::Free(aRegistryName);
if (newEntry)
delete newEntry;
}

View File

@ -69,7 +69,8 @@ protected:
nsresult RegistryNameForLib(const char *aLibName, char **aRegistryName);
nsresult RegisterComponentCommon(const nsCID &aClass,
const char *aClassName,
const char *aProgID, char *aRegistryName,
const char *aProgID,
const char *aRegistryName,
PRBool aReplace, PRBool aPersist,
const char *aType);
nsresult AddComponentToRegistry(const nsCID &aCID, const char *aClassName,