Closed
Bug 384803
Opened 17 years ago
Closed 17 years ago
nsStringBundle::FormatStringFromID should return nsMemory allocated strings
Categories
(Core :: Internationalization, defect)
Core
Internationalization
Tracking
()
RESOLVED
FIXED
People
(Reporter: prasad, Assigned: prasad)
Details
Attachments
(1 file, 1 obsolete file)
2.17 KB,
patch
|
timeless
:
review+
smontagu
:
review+
Biesinger
:
superreview+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.4) Gecko/20070508 Iceweasel/2.0.0.4 (Debian-2.0.0.4-1) Build Identifier: The FormatString function in nsStringBundle uses nsTextFormatter::smprintf, but nsTextFormatter does not use the shared nsMemory allocator. Instead it is recommended to free the memory it allocates using nsTextFormatter::smprintf_free. FormatString through FormatStringFromID is being used in a lot of other modules that do not have access to nsTextFormatter (non MOZILLA_INTERNAL_API code). Lets instead use nsMemory based allocation for the result that we give out and free the string returned by smprintf ourselves! Reproducible: Always
Assignee | ||
Comment 1•17 years ago
|
||
Stores the result from nsTextFormatter::smprintf to a temporary string, nsCRT::strdup it and then free the temporary string using nsTextFormatter::smprintf_free.
Attachment #268697 -
Flags: review?(smontagu)
Comment on attachment 268697 [details] [diff] [review] FormatString uses nsCRT::strdup to allocate the result buffer. >Index: intl/strres/src/nsStringBundle.cpp >@@ -380,28 +380,37 @@ nsStringBundle::FormatString(const PRUni >- *aResult = >+ PRUnichar *text = > nsTextFormatter::smprintf(aFormatStr, I believe this can fail, so you should add: if (!text) { *aResult = nsnull; return NS_ERROR_OUT_OF_MEMORY; } >+ // Instead it is recommended to free the memory it allocates using It is more of a requirement / demand than a recommendation. >+ // nsTextFormatter::smprintf_free. Lets instead use nsMemory based I think this should be "Let's" >+ *aResult = nsCRT::strdup(text); use NS_strdup
Attachment #268697 -
Flags: review?(smontagu) → review-
Assignee | ||
Comment 3•17 years ago
|
||
The patch is updated as per the comments by timeless.
Attachment #268697 -
Attachment is obsolete: true
Attachment #269068 -
Flags: review?(timeless)
Updated•17 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment on attachment 269068 [details] [diff] [review] FormatString uses NS_strdup to allocate the result buffer there should be a space between *aResult and ? :)
Attachment #269068 -
Flags: superreview?(cbiesinger)
Attachment #269068 -
Flags: review?(timeless)
Attachment #269068 -
Flags: review?(smontagu)
Attachment #269068 -
Flags: review+
Updated•17 years ago
|
Attachment #269068 -
Flags: superreview?(cbiesinger) → superreview+
Updated•17 years ago
|
Attachment #269068 -
Flags: review?(smontagu) → review+
Assignee | ||
Comment 5•17 years ago
|
||
timeless, can you checkin this patch for me? I guess you could add that space when checking it in.
Comment on attachment 269068 [details] [diff] [review] FormatString uses NS_strdup to allocate the result buffer mozilla/intl/strres/src/nsStringBundle.cpp 1.152
Assignee | ||
Updated•17 years ago
|
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Updated•17 years ago
|
Flags: in-testsuite-
You need to log in
before you can comment on or make changes to this bug.
Description
•