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)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Waldo, Assigned: benjamin)

References

()

Details

Attachments

(1 file, 1 obsolete file)

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.
Attached patch Actually set the parameter, rev. 1 (obsolete) (deleted) — Splinter Review
I am ashamed to have rewritten this code and flubbed this up.
Attachment #199238 - Flags: review?(darin)
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+
Final patch as checked in.
Attachment #199238 - Attachment is obsolete: true
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
So, this was also broken in Gecko 1.7?
That's correct.
OK, then I agree that it is probably best to not take this fix for Gecko 1.8
*** Bug 240478 has been marked as a duplicate of this bug. ***
Flags: in-testsuite?
Depends on: 505857
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: