Closed Bug 530901 Opened 12 years ago Closed 12 years ago

nsDOMFileReader::OnStopRequest can return |rv| without ever initializing it


(Core :: DOM: Core & HTML, defect)

Not set



Tracking Status
status1.9.2 --- beta4-fixed


(Reporter: dholbert, Assigned: sicking)




(1 file)

This warning on bsmedberg's warning tracker:
>  content/base/src/nsDOMFileReader.cpp:457: 'rv' may be used uninitialized in this function
[  ]
points out that "rv" in nsDOMFileReader::OnStopRequest can be returned without ever having been initialized.

Code snippet:
 457   nsresult rv;
 458   switch (mDataFormat) {
 459     case FILE_AS_BINARY:
 460       break; //Already accumulated mResult
 461     case FILE_AS_TEXT:
 462       rv = GetAsText(mCharset, mFileData, mDataLen, mResult);
 463       break;
 477   return rv;

In the FILE_AS_BINARY case, we leave rv unset -- and we later return it.  That's bad.

This affects both mozilla-central and mozilla-1.9.2.
I have no idea what this code does, but based on the "//Already accumulated mResult" comment, it sounds like we should just be setting rv = NS_OK there.

Jonas, is that correct?
Assignee: nobody → jonas
Blocks: 530220
No longer blocks: 507805
Attached patch Patch to fixSplinter Review
This is technically a better fix. If something goes wrong when converting the read data we now dispatch an error event.
Attachment #414397 - Flags: review?(jst)
Comment on attachment 414397 [details] [diff] [review]
Patch to fix

This fixes a minor bug and aligns us with the spec, I think we should land this for 1.9.2 while we still can.
Attachment #414397 - Flags: review?(jst)
Attachment #414397 - Flags: review+
Attachment #414397 - Flags: approval1.9.2+
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.