Closed Bug 18699 Opened 21 years ago Closed 21 years ago

[MLK] Leaking registryName

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: beard, Assigned: shaver)

References

()

Details

This string is being allocated by RegistryNameForLib(), but is never deallocated.
Here're diffs to fix these leaks:

Index: mozilla/xpcom/components/nsComponentManager.cpp
===================================================================
RCS file: /cvsroot/mozilla/xpcom/components/nsComponentManager.cpp,v
retrieving revision 1.94
diff -c -2 -r1.94 nsComponentManager.cpp
*** nsComponentManager.cpp	1999/11/14 15:41:40	1.94
--- nsComponentManager.cpp	1999/11/19 01:03:03
***************
*** 1475,1479 ****
  {
      return RegisterComponentCommon(aClass, aClassName, aProgID,
!                                    nsCRT::strdup(aLocation),
                                     aReplace, aPersist,
                                     aType);
--- 1475,1479 ----
  {
      return RegisterComponentCommon(aClass, aClassName, aProgID,
!                                    aLocation,
                                     aReplace, aPersist,
                                     aType);
***************
*** 1491,1496 ****
                                                PRBool aPersist)
  {
!     char *registryName;
!     nsresult rv = RegistryLocationForSpec(aLibrarySpec, &registryName);
      if (NS_FAILED(rv))
          return rv;
--- 1491,1496 ----
                                                PRBool aPersist)
  {
!     nsXPIDLCString registryName;
!     nsresult rv = RegistryLocationForSpec(aLibrarySpec,
getter_Copies(registryName));
      if (NS_FAILED(rv))
          return rv;
***************
*** 1500,1504 ****
                                     aReplace, aPersist,
                                     nativeComponentType);
-     nsAllocator::Free(registryName);
      return rv;
  }
--- 1500,1503 ----
***************
*** 1519,1524 ****
                                               PRBool aPersist)
  {
!     char *registryName;
!     nsresult rv = RegistryNameForLib(aDllName, &registryName);
      if (NS_FAILED(rv))
          return rv;
--- 1518,1523 ----
                                               PRBool aPersist)
  {
!     nsXPIDLCString registryName;
!     nsresult rv = RegistryNameForLib(aDllName, getter_Copies(registryName));
      if (NS_FAILED(rv))
          return rv;
***************
*** 1538,1542 ****
                                                  const char *aClassName,
                                                  const char *aProgID,
!                                                 char *aRegistryName,
                                                  PRBool aReplace,
                                                  PRBool aPersist,
--- 1537,1541 ----
                                                  const char *aClassName,
                                                  const char *aProgID,
!                                                 const char *aRegistryName,
                                                  PRBool aReplace,
                                                  PRBool aPersist,
***************
*** 1640,1645 ****
   out:
      if (NS_FAILED(rv)) {
-         if (aRegistryName)
-             nsAllocator::Free(aRegistryName);
          if (newEntry)
              delete newEntry;
--- 1639,1642 ----

Index: mozilla/xpcom/components/nsComponentManager.h
===================================================================
RCS file: /cvsroot/mozilla/xpcom/components/nsComponentManager.h,v
retrieving revision 1.44
diff -c -2 -r1.44 nsComponentManager.h
*** nsComponentManager.h	1999/11/10 00:28:29	1.44
--- nsComponentManager.h	1999/11/19 01:03:03
***************
*** 70,74 ****
      nsresult RegisterComponentCommon(const nsCID &aClass,
                                       const char *aClassName,
!                                      const char *aProgID, char *aRegistryName,
                                       PRBool aReplace, PRBool aPersist,
                                       const char *aType);
--- 70,75 ----
      nsresult RegisterComponentCommon(const nsCID &aClass,
                                       const char *aClassName,
!                                      const char *aProgID,
!                                      const char *aRegistryName,
                                       PRBool aReplace, PRBool aPersist,
                                       const char *aType);
*** Bug 19291 has been marked as a duplicate of this bug. ***
Status: NEW → ASSIGNED
Looks great, except for the gratuitous reformatting in the last patch-stanza.

r=shaver if you remove that. =)
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Beard checked in his fix (including the not-so-gratuitous |const| addition in
the last stanza).
Component: XPCOM Registry → XPCOM
QA Contact: dp → xpcom
You need to log in before you can comment on or make changes to this bug.