Closed Bug 334205 Opened 19 years ago Closed 19 years ago

nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode returns unitialized value if outUnicodeLen = 0

Categories

(Core :: Widget, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: timeless, Assigned: smontagu)

References

(Blocks 1 open bug, )

Details

(Keywords: coverity)

Attachments

(1 file, 3 obsolete files)

it's a rare case, in fact, it's probably virtually impossible. but the code should probably favor initializing rv to NS_OK and i wonder if GetMaxLength can fail :)
Attached patch patch (obsolete) (deleted) — Splinter Review
Assignee: general → smontagu
Status: NEW → ASSIGNED
Attachment #218658 - Flags: superreview?(jag)
Attachment #218658 - Flags: review?(timeless)
In fact I don't know how impossible this is: I don't see anything stopping inTextLen from being 0...
Comment on attachment 218658 [details] [diff] [review] patch This seems like the wrong patch. That rv is pretty much directly used in a do_GetService(..., &rv) which will always set it to something.
Attachment #218658 - Flags: superreview?(jag) → superreview-
Attached patch Patch the right place this time (obsolete) (deleted) — Splinter Review
You're right, I patched the wrong place, but do you have any objection to initializing both rvs to NS_OK? It seems like best practice to me.
Attachment #218658 - Attachment is obsolete: true
Attachment #218770 - Flags: superreview?(jag)
Attachment #218770 - Flags: review?(timeless)
Attachment #218658 - Flags: review?(timeless)
Attached patch Same, with incorrect comment removed (obsolete) (deleted) — Splinter Review
While I was there, removed a comment that has been inaccurate since rev 1.14. Sorry for the bugspam
Attachment #218771 - Flags: superreview?(jag)
Attachment #218771 - Flags: review?(timeless)
Attachment #218770 - Attachment is obsolete: true
Attachment #218770 - Flags: superreview?(jag)
Attachment #218770 - Flags: review?(timeless)
Comment on attachment 218771 [details] [diff] [review] Same, with incorrect comment removed I guess I would reorganize the code to make it more clear that rv gets properly initialized, something along the lines of: // get the charset nsresult rv; nsCOMPtr<nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); nsCAutoString platformCharset; if (NS_SUCCEEDED(rv)) rv = platformCharsetService->GetCharset(kPlatformCharsetSel_PlainTextInClipboard, platformCharset); if (NS_FAILED(rv)) platformCharset.AssignLiteral("ISO-8859-1"); Btw, am I missing something, or is |encoder| completely unused?
Attachment #218771 - Flags: superreview?(jag) → superreview+
Attached patch Updated to last comment (deleted) — Splinter Review
Attachment #218771 - Attachment is obsolete: true
Attachment #219510 - Flags: review?
Attachment #218771 - Flags: review?(timeless)
Attachment #219510 - Flags: review? → review?(timeless)
Attachment #219510 - Flags: review?(timeless) → review+
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: