Closed Bug 1133063 Opened 10 years ago Closed 10 years ago

base64 encoder/decoder should use fallible allocation

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: MatsPalmgren_bugz, Assigned: work, Mentored)

Details

(Whiteboard: [lang=c++])

Attachments

(1 file, 1 obsolete file)

Base64EncodeInputStream is used for base64-encoding blobs, canvas and is used by nsScriptableBase64Encoder: http://mxr.mozilla.org/mozilla-central/source/dom/workers/FileReaderSync.cpp#235 http://mxr.mozilla.org/mozilla-central/source/dom/html/HTMLCanvasElement.cpp#503 http://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsScriptableBase64Encoder.cpp#20 I think such uses should use fallible allocation, so we should change the SetLength calls in Base64.cpp to use the fallible version: http://mxr.mozilla.org/mozilla-central/source/xpcom/io/Base64.cpp#183 It already has some error checking for OOM there so it seems that fallible allocation was the original intention. Also, I think these should actually return the result from the call: http://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsScriptableBase64Encoder.cpp#20
See https://developer.mozilla.org/en-US/docs/Infallible_memory_allocation for an explanation of how to use fallible memory allocation.
Mentor: josh
Whiteboard: [lang=c++]
Summary: bas64 encoder/decoder should use fallible allocation → base64 encoder/decoder should use fallible allocation
Can I please work on this bug?
Attached patch Patch for bug 1133063 (obsolete) — Splinter Review
Attachment #8567506 - Flags: superreview?
Attachment #8567506 - Flags: review?(josh)
Assignee: nobody → titou125
Comment on attachment 8567506 [details] [diff] [review] Patch for bug 1133063 No need for a superreview. Those are not used much any more.
Attachment #8567506 - Flags: superreview?
Comment on attachment 8567506 [details] [diff] [review] Patch for bug 1133063 Review of attachment 8567506 [details] [diff] [review]: ----------------------------------------------------------------- Looks good to me! Let's get the review of Nathan, who owns this code (see https://wiki.mozilla.org/Modules/Core).
Attachment #8567506 - Flags: review?(nfroyd)
Attachment #8567506 - Flags: review?(josh)
Attachment #8567506 - Flags: feedback+
Comment on attachment 8567506 [details] [diff] [review] Patch for bug 1133063 Review of attachment 8567506 [details] [diff] [review]: ----------------------------------------------------------------- Looks good to me, with one minor change below. Please upload a new patch with the change and flag me for review. ::: xpcom/io/Base64.cpp @@ +184,1 @@ > if (aDest.Length() != count + aOffset) { Can you please move the SetLength call into the if's condition, like: if (!aDest.SetLength(count + aOffset, mozilla::fallible)) { ... }
Attachment #8567506 - Flags: review?(nfroyd) → feedback+
Attachment #8567506 - Attachment is obsolete: true
Attachment #8570000 - Flags: review?(nfroyd)
Comment on attachment 8570000 [details] [diff] [review] New patch for bug 1133063 Review of attachment 8570000 [details] [diff] [review]: ----------------------------------------------------------------- Thank you!
Attachment #8570000 - Flags: review?(nfroyd) → review+
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: