From fed38c19f8791f556bfea08ae763a1d4a764ecfa Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Fri, 19 Nov 1999 02:14:23 +0000 Subject: [PATCH] fix C string leak, bug=18699, r=shaver git-svn-id: svn://10.0.0.236/trunk@53951 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/components/nsComponentManager.cpp | 15 ++++++--------- mozilla/xpcom/components/nsComponentManager.h | 3 ++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 48147f152fc..d86dc91976d 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -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, ®istryName); + 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, ®istryName); + 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; } diff --git a/mozilla/xpcom/components/nsComponentManager.h b/mozilla/xpcom/components/nsComponentManager.h index 350d1c29005..c87c64d78c7 100644 --- a/mozilla/xpcom/components/nsComponentManager.h +++ b/mozilla/xpcom/components/nsComponentManager.h @@ -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,