Closed
Bug 267073
Opened 20 years ago
Closed 4 years ago
Fix code errors in nsStringBundle
Categories
(Core :: Internationalization, defect)
Tracking
()
RESOLVED
INACTIVE
People
(Reporter: timeless, Unassigned)
References
()
Details
(Keywords: good-first-bug, helpwanted)
Attachments
(1 file, 5 obsolete files)
|
6.91 KB,
patch
|
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
The url contains a code audit. Most of these are unchecked allocs, some trigger FMM, one references an undeclared variable, one isn't released at all, and there's an else after return for good measure. if you are interested in picking up this bug and need help figuring out the right allocator/release pair, note that the answer can be found by checking the header that declares the allocator.
Comment 1•20 years ago
|
||
i can try to play a little bit.
Updated•20 years ago
|
Whiteboard: [good first bug]
Comment 2•20 years ago
|
||
This should fix some of the problems. When I find time again, I'll look at the others (where I'll have to look a bit through lxr to see what's wrong).
Attachment #171641 -
Flags: review?(timeless)
Comment 3•20 years ago
|
||
Calling delete on a pointer allocated via ToNewCString is wrong. It should use nsMemory::Free.
Updated•20 years ago
|
Attachment #171641 -
Flags: review?(timeless)
Comment 5•20 years ago
|
||
I think asking timeless for review is the right idea... I won't have time for a real review of this patch for probably a week at least...
Updated•20 years ago
|
Attachment #171652 -
Flags: review?(bzbarsky) → review?(timeless)
Comment on attachment 171652 [details] [diff] [review] The same corrected thanks for working on this. >Index: intl/strres/src/nsStringBundle.cpp >@@ -248,17 +249,20 @@ nsStringBundle::GetStringFromID(PRInt32 > rv = LoadProperties(); > if (NS_FAILED(rv)) return rv; > > *aResult = nsnull; > nsAutoString tmpstr; it looks like rv isn't used past this point. could we replace ret with rv? > nsresult ret = GetStringFromID(aID, tmpstr); I think i'd rather an early return: if (NS_FAILED(ret)) return ret; /* i'd rather rv as mentioned above */ instead of this indented if block: > if (NS_SUCCEEDED(ret)) >+ { > *aResult = ToNewUnicode(tmpstr); >+ NS_ENSURE_TRUE(*aResult,NS_ERROR_OUT_OF_MEMORY); please include spaces after commas. (occurs a couple of times) >+ } > return ret; > } >@@ -268,17 +272,20 @@ nsStringBundle::GetStringFromName(const same comment >@@ -698,21 +705,17 @@ nsStringBundleService::recycleEntry(bund > } > > NS_IMETHODIMP > nsStringBundleService::CreateBundle(const char* aURLSpec, > nsIStringBundle** aResult) > { > #ifdef DEBUG_tao_ > printf("\n++ nsStringBundleService::CreateBundle ++\n"); >- { >- printf("\n** nsStringBundleService::CreateBundle: %s\n", >- aURLSpec ? aURLSpec : "null"); >- delete s; >- } >+ printf("\n** nsStringBundleService::CreateBundle: %s\n", this won't compile. > #endif > > return getStringBundle(aURLSpec,aResult); > }
Attachment #171652 -
Flags: review?(timeless) → review-
Comment 7•20 years ago
|
||
How about that?
Attachment #171641 -
Attachment is obsolete: true
Attachment #171652 -
Attachment is obsolete: true
Attachment #171747 -
Flags: review?(timeless)
Comment 8•20 years ago
|
||
Comment on attachment 171747 [details] [diff] [review] Corrected version Sorry timeless, I found some mistakes myself...
Attachment #171747 -
Flags: review?(timeless)
Comment 9•20 years ago
|
||
Now, this should be better. I'm afraid it took some time, but I completely forgot about uploading that patch...
Attachment #171747 -
Attachment is obsolete: true
Attachment #172379 -
Flags: review?(timeless)
(In reply to comment #9) > Created an attachment (id=172379) [edit] > More fixes > > Now, this should be better. I'm afraid it took some time, but I completely > forgot about uploading that patch... timeless asked me to look at the patch - nsStringBundle::GetCombinedEnumeration has some marked lines that you don't seem to touch. Do those not need to be fixed? 291, 292, and 299 look ok to me, but I think the return value from line 284 needs to be checked.
Comment 11•20 years ago
|
||
I don't see what needs to be checked in 284 (ENSURE_TRUE(*aResult...) is already present), please tell me what you mean (the same would be for 261). I know I haven't yet corrected all errors, as I've had not much time and it was not completely clear to me what to do there. But I'll look at them as soon as possible.
Comment 12•20 years ago
|
||
Found what to do therefore, it wasn't really that hard...
Comment 13•20 years ago
|
||
Does lines are fixed now, please let me know what additional checks you want!
Updated•20 years ago
|
Attachment #172379 -
Attachment is obsolete: true
Attachment #172572 -
Flags: review?(cst)
Updated•20 years ago
|
Attachment #172379 -
Flags: review?(timeless)
Comment on attachment 172572 [details] [diff] [review] patch Sorry, I'm not a peer for the relevant module, so I can't actually r+ the patch (it looks good to me, though).
Attachment #172572 -
Flags: review?(cst) → review?(smontagu)
Updated•20 years ago
|
Attachment #172572 -
Flags: review?(smontagu) → review+
Updated•20 years ago
|
Attachment #172572 -
Flags: superreview?(timeless)
| Reporter | ||
Comment 15•20 years ago
|
||
Comment on attachment 172572 [details] [diff] [review] patch sorry, i'm not an sr. but thanks for working on this :). + rv=GetStringFromID(aID, tmpstr); + rv=NS_NewArray(getter_AddRefs(resultArray)); + rv=propEnumerator->HasMoreElements(&hasMore); to match the style for this file, you should have spaces around the = .
Attachment #172572 -
Flags: superreview?(timeless) → superreview?(bzbarsky)
Comment 16•20 years ago
|
||
Is it important to follow the style of a particular file up to those details?
Comment 17•20 years ago
|
||
Do you have any reason not to? Mozilla.org doesn't impose any particular coding style, but within a single file (or depending on the situation, within a single directory or a single module), the consistency is a good thing (TM).
| Reporter | ||
Comment 18•20 years ago
|
||
yes: http://www.mozilla.org/hacking/mozilla-style-guide.html#Visual
Attachment #172667 -
Flags: superreview?(bzbarsky)
Attachment #172572 -
Flags: superreview?(bzbarsky)
Comment 20•20 years ago
|
||
Comment on attachment 172667 [details] [diff] [review] with spaces changed sr=bzbarsky. Let me know if this needs landing (though I assume timeless will check this in).
Attachment #172667 -
Flags: superreview?(bzbarsky) → superreview+
Updated•20 years ago
|
Assignee: smontagu → domob
Comment 21•20 years ago
|
||
Checked in on trunk for 1.8b. Not resolving, since I'm not sure whether there is more to be done here.
Comment 22•20 years ago
|
||
This patch introduced a bunch of meaningless assertions. It is not illegal for GetStringFromName to fail. I'm not even sure that it is illegal for LoadProperties to fail, but I do think that NS_ENSURE_SUCCESS is overkill.
Updated•15 years ago
|
QA Contact: amyy → i18n
Updated•5 years ago
|
Keywords: good-first-bug
Whiteboard: [good first bug]
Comment 23•4 years ago
|
||
This good-first-bug hasn't had any activity for 6 months, it is automatically unassigned.
For more information, please visit auto_nag documentation.
Assignee: domob → nobody
Updated•4 years ago
|
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INACTIVE
You need to log in
before you can comment on or make changes to this bug.
Description
•