Closed
Bug 281066
Opened 20 years ago
Closed 13 years ago
removing some memory allocations from mimedrft.cpp
Categories
(MailNews Core :: MIME, defect)
MailNews Core
MIME
Tracking
(Not tracked)
RESOLVED
WORKSFORME
People
(Reporter: tim.ruehsen, Unassigned)
References
Details
(Whiteboard: [patchlove][has patch])
Attachments
(3 obsolete files)
User-Agent: Mozilla/5.0 (compatible; Konqueror/3.3; Linux) KHTML/3.3.2 (like Gecko) Build Identifier: Mainly replacing calls to NS_MsgSACat and NS_MsgSACopy by PR_smprintf and PL_strdup. Rewrote mime_fix_up_html_address which was buggy. Found one PL_strncpy usage without terminating (in MimeGetNamedString()). Replaced some PR_Free() by PR_FREEIF(). Reproducible: Always
| Reporter | ||
Comment 1•20 years ago
|
||
Updated•20 years ago
|
Assignee: general → sspitzer
Component: General → MailNews: MIME
Product: Mozilla Application Suite → Core
QA Contact: general
Version: unspecified → Trunk
Comment 2•20 years ago
|
||
Please request reviews from the appropriate peers listed at http://www.mozilla.org/owners.html
| Reporter | ||
Updated•20 years ago
|
Attachment #173364 -
Flags: review?(kaie)
Comment 3•20 years ago
|
||
I'm not sure if Kaie is still doing mail reviews. Perhaps you could take a look at this, David?
Updated•20 years ago
|
Attachment #173364 -
Flags: review?(kaie) → review?(bienvenu)
Comment 4•20 years ago
|
||
the difference between PR_FREEIF and PR_Free is that PR_FREEIF nulls out the resulting pointer. I don't believe you need that behaviour (PR_Free also checks for null). Can I get a -uw diff so I don't have to see the whitespace-only changes?
| Reporter | ||
Comment 5•20 years ago
|
||
Hey, that w option is what I needed. Formerly, I removed these line by hand. After all, we are talking about 2 occurrences in a total of ~150...sigh. In some cases I use PR_FREEIF not because it tests the pointer but because it sets it to 0 after freeing. For debugging/security reasons this should be done wherever it can. The cost for this is very small and using a 0 pointer would make the app crash immediately and not somewhere else, which makes it hard to track down the real problem. But doing so seem to disturb some people (typical arguments are: 'hey, are you a girl or what?' ;-).
Attachment #174659 -
Flags: review?(bienvenu)
| Reporter | ||
Updated•20 years ago
|
Attachment #173364 -
Attachment is obsolete: true
Attachment #173364 -
Flags: review?(bienvenu)
| Reporter | ||
Comment 7•20 years ago
|
||
I replaced some PR_FREEIF by PR_Free or PR_DELETE where it was obvious that it could be done. But PR_Free does not check for null (see prmem.c). My opinion still is: we should ONLY use PR_FREEIF and make PR_Free and PR_DELETE obsolete. This is because here and there PR_Free and PR_DELETE are used even when it is not obviously the right choice (or even definitely wrong). This may come from copy&paste and/or inattentiveness. PR_FREEIF would really help. I just realized that there where some syntax errors in the patches before. They are fixed by now. Still there are some warnings like 'converting of negative value `-1000' to `unsigned' e.g. in function mime_decompose_file_init_fn
Attachment #174659 -
Attachment is obsolete: true
| Reporter | ||
Updated•20 years ago
|
Attachment #174674 -
Flags: review?(bienvenu)
Comment 8•20 years ago
|
||
the underlying c library free checks for null. Nulling out a pointer inside a memory block that you're about to free anyway is usually a waste of code size and cpu cycles, unless the information is scary to leave in memory, like a password.
| Reporter | ||
Comment 9•20 years ago
|
||
ok. anything blocking the patch from going into cvs?
Updated•20 years ago
|
Attachment #174674 -
Flags: review?(bienvenu) → review?(ducarroz)
Updated•20 years ago
|
Attachment #174659 -
Flags: review?(bienvenu)
Comment 10•20 years ago
|
||
Comment on attachment 174674 [details] [diff] [review] cvs diff for mimedrft.cpp + if (tmp) + { + PR_FREEIF(*body); + *body = tmp; + } this should just be: ... PR_Free(*body); similarly, - PR_FREEIF(result); } + PR_FREEIF(result); PR_Free(result); etc. PR_FREEIF also stores a null in the resulting pointer, which we don't need.
| Reporter | ||
Comment 11•20 years ago
|
||
#10: this is a question of flavour (maybe experience?) To avoid possible issues with future copy&paste or changes in the code, I *personally* would always use PR_FREEIF(). This is generally called 'defensive'. In fact, I saw it happen 'often', that little changes on 'perfect' code lead to problems with 'freed twice' allocations (among many other possible problems). So, no. I disagree to change that. But I won't try to argue if you insist on the changes. I am a bit out of the mozilla project.
Comment 12•20 years ago
|
||
Comment on attachment 174674 [details] [diff] [review] cvs diff for mimedrft.cpp Very good cleanup. But you are leaking the utf8 variable in mime_intl_insert_message_header_1
Attachment #174674 -
Flags: review?(ducarroz) → review-
| Reporter | ||
Comment 13•20 years ago
|
||
Thanks, Jean-Francois. There should be a PR_FREEIF(utf8) or PR_Free(utf8) at the end of mime_intl_insert_message_header_1(). Could someone insert it, please. I am out of mozilla for a while and have no time to work into it at the moment.
Comment 14•17 years ago
|
||
sorry for the spam. making bugzilla reflect reality as I'm not working on these bugs. filter on FOOBARCHEESE to remove these in bulk.
Assignee: sspitzer → nobody
Updated•16 years ago
|
QA Contact: mime
| Assignee | ||
Updated•16 years ago
|
Product: Core → MailNews Core
Updated•15 years ago
|
Severity: enhancement → minor
Whiteboard: [patchlove][has patch]
Comment 15•14 years ago
|
||
Comment on attachment 174674 [details] [diff] [review] cvs diff for mimedrft.cpp Patch has bitrotted. Tim, up for a new patch? :) $ patch -p0 --dry-run < ~/Desktop/p281066.diff patching file mimedrft.cpp Hunk #1 FAILED at 573. Hunk #2 FAILED at 649. Hunk #3 FAILED at 895. Hunk #4 succeeded at 937 with fuzz 2 (offset -22 lines). Hunk #5 FAILED at 1046. Hunk #6 FAILED at 1090. Hunk #7 FAILED at 1121. Hunk #8 succeeded at 1183 (offset -20 lines). Hunk #9 FAILED at 1314. Hunk #10 FAILED at 1424. Hunk #11 FAILED at 1504. Hunk #12 FAILED at 1531. Hunk #13 FAILED at 1562. Hunk #14 FAILED at 1722. Hunk #15 succeeded at 1816 with fuzz 2 (offset 17 lines). Hunk #16 FAILED at 1841. Hunk #17 FAILED at 1921. 14 out of 17 hunks FAILED -- saving rejects to file mimedrft.cpp.rej
Attachment #174674 -
Attachment is obsolete: true
Comment 16•13 years ago
|
||
Is this patch still relevant?Should I update it? What needs to be done? Are comment 10 and comment 13 the only problems with it? David, should all changes of PR_Free to PR_FREEIF be reverted (removed in the patch)? Or do you object only to some specific occurrences?
Comment 17•13 years ago
|
||
(In reply to :aceman (away 16.-21.) from comment #16) > Is this patch still relevant?Should I update it? No, I don't think so. I made a bunch of changes to mimedrft.cpp to clean up the string usage (using nsCString, which allows for much cleaner memory mgmt), so it's unlikely the patch is relevant.
Comment 18•13 years ago
|
||
But there are many other changes, like NS_MsgSACopy removal. Is nothing from it usable?
Comment 19•13 years ago
|
||
(In reply to :aceman (away 16.-21.) from comment #18) > But there are many other changes, like NS_MsgSACopy removal. Is nothing from > it usable? No, I think the code has changed so much that you'd have to start over from the beginning.
Comment 20•13 years ago
|
||
It seems this whole bug is filed for making the changes in the attached patch. If that is not relevant anymore, probably the whole bug is not needed now?
Comment 21•13 years ago
|
||
Wayne? Any idea with this bug?
Comment 22•13 years ago
|
||
(In reply to :aceman from comment #20) > It seems this whole bug is filed for making the changes in the attached > patch. If that is not relevant anymore, probably the whole bug is not needed > now? I don't know, but it sounds like ...
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•