Open
Bug 58423
Opened 24 years ago
Updated 2 years ago
mTitle.ToNewCString(); not assigned to anything
Categories
(Core :: XUL, defect, P3)
Tracking
()
NEW
Future
People
(Reporter: jag+mozbugs, Unassigned)
References
()
Details
Attachments
(3 files)
581 bytes,
patch
|
Details | Diff | Splinter Review | |
2.08 KB,
patch
|
Details | Diff | Splinter Review | |
6.41 KB,
patch
|
Details | Diff | Splinter Review |
313 char *title = ConvertToFileSystemCharset(mTitle.GetUnicode()); 314 if (nsnull == title) 315 mTitle.ToNewCString(); Line 315 should probably be something like line 124: 122 char *title = ConvertToFileSystemCharset(mTitle.GetUnicode()); 123 if (nsnull == title) 124 title = mTitle.ToNewCString();
Reporter | ||
Comment 1•24 years ago
|
||
Adding keywords, attaching patch.
Reporter | ||
Comment 2•24 years ago
|
||
Reporter | ||
Comment 3•24 years ago
|
||
This is a leak. Not a serious one, but still a leak. Making summary a bit more clear on that.
Summary: mTitle.ToNewCString(); not assigned to anything → [mlk] mTitle.ToNewCString(); not assigned to anything
Comment 5•24 years ago
|
||
r=nhotta
Comment 6•24 years ago
|
||
I added the mlk keyword, can you remove the summary [mlk] noise-word? It seems this code always used delete[] title (in both places) if title was non-null, yet it wanted to set title from the ConvertToFileSystemCharset, which returns new char[], or failing that, from the ToNewCString result, which IIRC returns nsMemory::Alloc'd code. So doesn't this mean that sometimes, purify will complain about a mismatch? I say fix ConvertToFileSystemCharset to use nsMemory too. /be
Keywords: mlk
Comment 7•24 years ago
|
||
I agree with changing it to use nsMemory. I think ToNewCString used to be freed by delete[].
Status: NEW → ASSIGNED
Summary: [mlk] mTitle.ToNewCString(); not assigned to anything → mTitle.ToNewCString(); not assigned to anything
Comment 8•24 years ago
|
||
disttsc@bart.nl, do you also want to do the memory allocation change?
Reporter | ||
Comment 9•24 years ago
|
||
Reporter | ||
Comment 10•24 years ago
|
||
Here's a first cut... I don't have access to a Windows machine to test compile on though (and hunting someone down in #mozilla has so far proven unsuccessful), so this is untested. I've currently only changed the (de)allocations for the functions and variables directly affected, if so desired changing ConvertFromFileSystemCharset and its callers shouldn't be too hard either.
Reporter | ||
Comment 11•24 years ago
|
||
Comment 12•24 years ago
|
||
Thanks, please also change ConvertFromFileSystemCharset. Since I only know the code around the charset conversion, you should also get a review from the module owner of this file.
Reporter | ||
Comment 13•24 years ago
|
||
nhotta: check patch #3 ;-)
Comment 14•24 years ago
|
||
r=nhotta It compiled on windows. As I said, the first half of the patch does not related to charset conversion, please find a module owner of widget to get a review. I tested with the patch, and put a break point at nsFileWidget::Show but it didn't break when I used open dialog and save dialog. The code might not be used anymore. Cc to pinketon. Mike, who is a module owner of widget? I cannot find in http://www.mozilla.org/owners.html
Comment 15•24 years ago
|
||
there is no real module owner for widget, though rods claims it for win32, pav claims it for linux, and we tagteam for mac.
Comment 16•24 years ago
|
||
jag: you inverted some if (NULL == converted), etc., tests and used if (converted), which is cool -- I don't see any incompatible change there, but I question the original code (which you didn't write) covering up out-of-memory errors. Worth fixing now? Do in a later bug? XXX comment now if the latter. Here is a change I think that's not compatible, or a bugfix: - if (NS_SUCCEEDED(rv)) - rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, aCharset); - NS_ASSERTION(NS_SUCCEEDED(rv), "error getting platform charset"); - if (NS_FAILED(rv)) - aCharset.AssignWithConversion("windows-1252"); + + if (NS_SUCCEEDED(rv)) + rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, aCharset); + else + aCharset.AssignWithConversion("windows-1252"); The old code would fall back on "windows-1252" if anything failed, early or late. You fall back only in the earlier failure, and ignore a later failure in GetCharset. See what I mean? /be
Reporter | ||
Comment 17•24 years ago
|
||
Doh! Yes, I see what you mean. I thought I had checked for that... Okay, so I'll undo that whole change :-) Re: out-of-memory errors: looking into it. cc'ing rods for review / input on this code.
Comment 18•24 years ago
|
||
We can check in the first patch for the memory leak now. I'll ask brendan for an approval.
Comment 19•24 years ago
|
||
Sure -- sr= on the first patch, but please finish up the related cleanups too, they make the code significantly better, and should not be dropped on the floor. Thanks, /be
Comment 20•24 years ago
|
||
sr=brendan@mozilla.org on the first (one-line) patch, I mean. /be
Reporter | ||
Comment 22•24 years ago
|
||
Cool, thanks :-) nhotta: Shall I attach the last patch with the correction Brendan pointed out? I can look at his other comments (current out of memory cover-ups, converting to String code istead of manually allocating/freeing memory) later this month, so if you can do that sooner, that'd be cool.
Comment 23•24 years ago
|
||
Yes, please attach the patch. I reassign to you since you're actually fixing it. I can help you to check in. Also please get a review from xptool kit group like rods since the rest of the changes are mostly not in international code.
Assignee: nhotta → disttsc
Status: ASSIGNED → NEW
Updated•16 years ago
|
Assignee: jag → nobody
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•