Closed Bug 25615 Opened 26 years ago Closed 26 years ago

[MLK] nsStdURL leaking C strings

Categories

(Core :: Networking, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: beard, Assigned: andreas.otte)

References

()

Details

At the CVS blame URL above, you will see a call to DupString(&mRef, ...) where mRef can already have a pointer to a C string in it, thus duping over it leaks memory. There are a few other call sites to DupString() in this file that look suspicious to me. The proof is that the following patch removes the memory leaks that I'm observing with the Boehm leak detector: Index: mozilla/netwerk/base/src/nsStdURL.cpp =================================================================== RCS file: /cvsroot/mozilla/netwerk/base/src/nsStdURL.cpp,v retrieving revision 1.39 diff -c -2 -r1.39 nsStdURL.cpp *** nsStdURL.cpp 2000/01/28 07:40:31 1.39 --- nsStdURL.cpp 2000/01/29 03:04:29 *************** *** 824,827 **** --- 824,828 ---- ? and ; as well. */ + CRTFREEIF(mRef); nsresult status = DupString(&mRef, (i_Ref && (*i_Ref == '#')) ? (i_Ref+1) : i_Ref); *************** *** 832,835 **** --- 833,837 ---- nsStdURL::SetParam(const char* i_Param) { + CRTFREEIF(mParam); nsresult status = DupString(&mParam, (i_Param && (*i_Param == ';')) ? (i_Param+1) : i_Param); *************** *** 840,843 **** --- 842,846 ---- nsStdURL::SetQuery(const char* i_Query) { + CRTFREEIF(mQuery); nsresult status = DupString(&mQuery, (i_Query && (*i_Query == '?')) ? (i_Query+1) : i_Query);
re-assign this to warren. the reason my name was on the code was because I backed out warren. cc'ing andreas as well.
Assignee: sspitzer → warren
Target Milestone: M14
Already included in ANDREAS_URL2_BRANCH
Andreas, Is this fixed now?
Assignee: warren → andreas.otte
Yes, this CStrings no longer leak.
Status: NEW → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
marking verified per engineer's comments
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.