Closed Bug 111296 Opened 23 years ago Closed 22 years ago

[W] MLK: Memory leak of 34 bytes from 2 blocks allocated in PL_strdup

Categories

(Core :: XPCOM, defect)

x86
Windows NT
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 132126
Future

People

(Reporter: naving, Assigned: dougt)

Details

(Keywords: helpwanted)

Attachments

(1 file)

Steps to reproduce

1) Launch mail
2) read message, switch folders
2) Compose and send a message
3) quit

        Distribution of leaked blocks
        Allocation location
            malloc         [dbgheap.c:129]
            PL_strdup      [strdup.c:46]
            nsCRT::strdup(char const*) [nsCRT.h:182]
            nsFactoryEntry::ReInit(nsID const&,char const*,int) 
[nsComponentManager.cpp:430]
                    // SERVICE_ONLY entries can be promoted to an entry of 
another type
                    NS_ENSURE_TRUE((typeIndex == NS_COMPONENT_TYPE_SERVICE_ONLY 
|| cid.Equals(aClass)),
                                   NS_ERROR_INVALID_ARG);
             =>     location = nsCRT::strdup(aLocation);
                    typeIndex = aType;
                    return NS_OK;
                }
            nsComponentManagerImpl::RegisterComponentCommon(nsID const&,char 
const*,char const*,char const*,int,int,char const*) 
[nsComponentManager.cpp:2390]
                    }
                
                    if (entry) {
             =>         entry->ReInit(aClass, aRegistryName, typeIndex);
                    }
                    else {
                        entry = new nsFactoryEntry(aClass, aRegistryName, 
typeIndex);
            nsComponentManagerImpl::RegisterComponentWithType(nsID const&,char 
const*,char const*,nsIFile *,char const*,int,int,char const*) 
[nsComponentManager.cpp:2273]
            nsComponentManagerImpl::RegisterComponentSpec(nsID const&,char 
const*,char const*,nsIFile *,int,int) [nsComponentManager.cpp:2295]
            nsPluginHostImpl::RegisterPluginMimeTypesWithLayout(nsPluginTag 
*,nsIComponentManager *,nsIFile *) [nsPluginHostImpl.cpp:3542]
            nsPluginHostImpl::ScanPluginsDirectory(nsIFile *,nsIComponentManager 
*,nsIFile *,int) [nsPluginHostImpl.cpp:4541]
            nsPluginHostImpl::LoadPlugins(void) [nsPluginHostImpl.cpp:4654]
--> XPCOM Registry?
Assignee: av → dougt
Component: Plug-ins → XPCOM Registry
QA Contact: shrir → dougt
Component: XPCOM Registry → XPCOM
Target Milestone: --- → mozilla0.9.7
Keywords: helpwanted
Target Milestone: mozilla0.9.7 → Future
From just reading the code:

If ReInit() gets called more than once it will just do:
|location = nsCRT::strdup(aLocation)|
thus dropping the old reference on the floor. This patch makes it free it if it
is allocated before trying to strdup() again. 

Am I missing something in the big picture?
Would neeti or dp care to make a comment about the fix? Those are the two names
that show up in cvsblame around the code.
Comment on attachment 69990 [details] [diff] [review]
Patch to avoid dropping the old reference.

r=dougt
Attachment #69990 - Flags: review+
ah! I remember typing a comment on this bug. Maybe I wasnt logged in and got the
login screen instead of an add to the bug.

The plan is to arena allocate location. Longer term plan is to store a hash
instead of the string.

Yeah good fixing this leak. But bug 130381 will obsolete this fix as it will
arena allocate the location string. I am waiting on approval to check it in.
Bug 132126 contains an identical patch to this one that was checked in on trunk
today. This bug should probably be marked as a dupe of that.

*** This bug has been marked as a duplicate of 132126 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
vrfy, sorry for filing the duplicate, but this bug was unfindable given the summary.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: