Closed Bug 1487310 Opened 2 years ago Closed 2 years ago

LossyUTF8ToUTF16() in nsNSSCertHelper.cpp uselessly uses ToNewUnicode()

Categories

(Core :: Security: PSM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: hsivonen, Assigned: hsivonen)

Details

Attachments

(1 file)

LossyUTF8ToUTF16() in nsNSSCertHelper.cpp uses XPCOM string conversions in an awkward way. Instead of ToNewUnicode() + Adopt(), it should use strings in a regular non-Adopt() way.
This does not change the outward behavior of LossyUTF8ToUTF16(). Both
ToNewUnicode() and CopyASCIItoUTF16() convert from Latin1 to UTF-16.

MozReview-Commit-ID: 8SDgvoGaN4A
Aside: The original motivation in bug 1461037 was to avoid assertions when UTF-8 is bogus. Nowadays UTF-8 to UTF-16 conversion replaces errors with the REPLACEMENT CHARACTER instead of asserting.
Comment on attachment 9005109 [details]
Bug 1487310 - Let XPCOM strings manage their own buffer in LossyUTF8ToUTF16().

Dana Keeler [:keeler] (she/her) (use needinfo) has approved the revision.
Attachment #9005109 - Flags: review+
Pushed by hsivonen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c45b51ec248e
Let XPCOM strings manage their own buffer in LossyUTF8ToUTF16(). r=keeler
https://hg.mozilla.org/mozilla-central/rev/c45b51ec248e
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.