Closed
Bug 312000
Opened 19 years ago
Closed 19 years ago
nsICategoryManager::AddCategoryEntry doesn't return the previous value of the entry (if any)
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
People
(Reporter: Waldo, Assigned: benjamin)
References
()
Details
Attachments
(1 file, 1 obsolete file)
(deleted),
patch
|
Details | Diff | Splinter Review |
AddCategoryEntry's IDL comments specify that it returns the previous value of
the entry in the specified category (if any such value existed). The current
implementation, however, doesn't actually set this value. (It looks like the
implementation before 2003 actually did return the value.)
Somewhat tangentially, the IDL comments don't really say whether the current
value of the entry is returned if the fifth parameter |aReplace| is set to
PR_FALSE. The previous behavior should probably be duplicated, and ideally this
could be clarified in IDL comments.
Assignee | ||
Comment 1•19 years ago
|
||
I am ashamed to have rewritten this code and flubbed this up.
Attachment #199238 -
Flags: review?(darin)
Comment 2•19 years ago
|
||
Comment on attachment 199238 [details] [diff] [review]
Actually set the parameter, rev. 1
>+ // this hunk of code is "strdup" with the XPCOM allocator
>+ int toDupLen = strlen(toDup);
>+ *_retval = NS_Alloc(toDupLen + 1);
>+ if (!*_retval)
>+ return NS_ERROR_OUT_OF_MEMORY;
>+
>+ memcpy(*_retval, toDup, toDupLen + 1);
This also works:
*_retval = ToNewCString(nsDependentCString(toDup));
You could also just use nsCRT::strdup because that is what
we use everywhere else. Then, we should go file a bug to
fix nsCRT::strdup to actually use NS_Alloc.
r=darin either which way
Attachment #199238 -
Flags: review?(darin) → review+
Assignee | ||
Comment 3•19 years ago
|
||
Final patch as checked in.
Attachment #199238 -
Attachment is obsolete: true
Assignee | ||
Comment 4•19 years ago
|
||
Fixed on trunk. Darin, I'm not sure whether I want this for branch or not: it's
a definite correctness fix for a frozen interface, but we probably haven't
audited callers in a long time.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment 5•19 years ago
|
||
So, this was also broken in Gecko 1.7?
Assignee | ||
Comment 6•19 years ago
|
||
That's correct.
Comment 7•19 years ago
|
||
OK, then I agree that it is probably best to not take this fix for Gecko 1.8
Comment 8•19 years ago
|
||
*** Bug 240478 has been marked as a duplicate of this bug. ***
Reporter | ||
Updated•17 years ago
|
Flags: in-testsuite?
You need to log in
before you can comment on or make changes to this bug.
Description
•