Closed Bug 569026 Opened 14 years ago Closed 14 years ago

e10s HTTP: add check for string length to OnDataAvailable

Categories

(Core :: Networking: HTTP, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jduell.mcbugs, Assigned: jduell.mcbugs)

References

Details

Attachments

(1 file, 1 obsolete file)

Attached patch check string length after setting it. (obsolete) (deleted) — Splinter Review
Jonas pointed out to me that nsCString.SetLength() will silently fail if memory allocation (which doesn't yet use infallible malloc) fails, and that you have to check Length() to make sure it worked. I've also documented this in our String docs (which made no mention of it, and had an example that didn't check): https://developer.mozilla.org/En/Mozilla_internal_string_guide Also, EndWriting() is not needed here.
Attachment #448176 - Flags: review?(jonas)
Blocks: fennecko
I noticed another error with this code: if (!NS_SUCCEEDED(rv) || bytesRead != aCount) { return rv; // TODO: cancel request (bug 536317) According to nsIInputStream.idl, read can return less than the asked-for amount, but still succeed, so rv may not be set to an error code if bytesRead != aCount. Replaced with a while loop that tries to read until aCount is reached, or EOF is hit. Probably not needed in practice (Read has always read all the bytes so far during testing), but it's what the API technically requires, unless I'm mistaken.
Assignee: nobody → jduell.mcbugs
Attachment #448176 - Attachment is obsolete: true
Attachment #448179 - Flags: review?(jonas)
Attachment #448176 - Flags: review?(jonas)
Fixed as part of bug 536317
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: