Open
Bug 39110
Opened 25 years ago
Updated 2 years ago
PR_FREEIF macro is dangerous
Categories
(NSPR :: NSPR, defect, P3)
NSPR
NSPR
Tracking
(Not tracked)
NEW
Future
People
(Reporter: erik, Unassigned)
Details
Attachments
(1 file)
1.13 KB,
patch
|
Details | Diff | Splinter Review |
The PR_FREEIF macro is dangerous. If it is followed by "else", it will give an
unexpected result:
if (foo)
PR_FREEIF(ptr);
else
blah();
I suggest putting PR_BEGIN_MACRO and PR_END_MACRO around the relevant macros.
Comment 1•25 years ago
|
||
The nested if-else problem.
The fix you suggested is the right one.
Status: NEW → ASSIGNED
Target Milestone: --- → 4.0.1
Updated•25 years ago
|
Target Milestone: 4.0.1 → 4.1
Comment 2•25 years ago
|
||
In fact the sample code:
if (foo)
PR_FREEIF(ptr);
else
blah();
won't even compile because of the way
PR_DELETE is defined. (PR_FREEIF uses
PR_DELETE.) So PR_DELETE also needs
to be fixed.
I'm going to attach a patch that changes
PR_DELETE and PR_FREEIF to use PR_BEGIN_MACRO
and PR_END_MACRO.
Comment 3•25 years ago
|
||
Comment 4•25 years ago
|
||
The patch is checked in on the main trunk.
/cvsroot/mozilla/nsprpub/pr/include/prmem.h, revision 3.7
Added a new test freeif.c which contains Erik's
sample code.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Comment 5•25 years ago
|
||
It was pointed out to me that some code
is depending on the current broken definition
of PR_DELETE and PR_FREEIF. For example,
some files contain instances of PR_FREEIF(ptr)
that don't end with ';'.
I'm going to defer this change to the next
major release, NSPR 5.0, because it breaks
backward compatibility at source level.
Backed out the checkin.
/cvsroot/mozilla/nsprpub/pr/include/prmem.h, revision 3.8
The test freeif.c is removed from the makefile and test
harness.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 4.1 → Future
Updated•25 years ago
|
Status: REOPENED → ASSIGNED
Are PR_DELETE and PR_FREEIF still broken?
As comment #5 seems to indicate that his bug is dependant on these...
Updated•18 years ago
|
QA Contact: wtchang → nspr
Comment 7•3 years ago
|
||
The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.
Assignee: wtc → nobody
Status: ASSIGNED → NEW
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•