Closed Bug 801483 Opened 7 years ago Closed 7 years ago

make nsBufferedInputStream::Init fallible

Categories

(Core :: Networking, defect)

x86
Windows 7
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: m_kato, Assigned: m_kato)

Details

(Keywords: crash)

Crash Data

Attachments

(1 file, 2 obsolete files)

crash id is bp-f7294fd5-e5d4-4c5f-81ea-86b722121012 .

I think that nsIBufferedInputStream.init should return out of memory error if buffer parameter is too big or we cannot allocate memory.
Attached patch fix (obsolete) — Splinter Review
Attachment #671287 - Flags: review?(honzab.moz)
Please change NS_NewBufferedInputStream to have MOZ_WARN_UNUSED_RESULT, and change the callers of NS_NewBufferedInputStream to handle the error correctly and/or forward the correct error code. I noticed three problems:

#1: Will crash because the code assumes NS_NewBufferedInputStream always succeeds:
http://mxr.mozilla.org/mozilla-central/source/layout/base/nsPresShell.cpp#8117

#2, #3: Returns the wrong error code:
http://mxr.mozilla.org/mozilla-central/source/netwerk/cache/nsDiskCacheDeviceSQL.cpp#1747
http://mxr.mozilla.org/mozilla-central/source/dom/devicestorage/nsDeviceStorage.cpp#362
(In reply to Brian Smith (:bsmith) from comment #2)
> Please change NS_NewBufferedInputStream to have MOZ_WARN_UNUSED_RESULT, and
> change the callers of NS_NewBufferedInputStream to handle the error
> correctly and/or forward the correct error code. I noticed three problems:
> 
> #1: Will crash because the code assumes NS_NewBufferedInputStream always
> succeeds:
> http://mxr.mozilla.org/mozilla-central/source/layout/base/nsPresShell.
> cpp#8117
> 
> #2, #3: Returns the wrong error code:
> http://mxr.mozilla.org/mozilla-central/source/netwerk/cache/
> nsDiskCacheDeviceSQL.cpp#1747
> http://mxr.mozilla.org/mozilla-central/source/dom/devicestorage/
> nsDeviceStorage.cpp#362

OK. I will fix this.
Attachment #671287 - Flags: review?(honzab.moz)
Attached patch fix (obsolete) — Splinter Review
Assignee: nobody → m_kato
Attachment #671287 - Attachment is obsolete: true
Attached patch fixSplinter Review
Attachment #671346 - Attachment is obsolete: true
Attachment #671349 - Flags: review?(honzab.moz)
Comment on attachment 671349 [details] [diff] [review]
fix

Review of attachment 671349 [details] [diff] [review]:
-----------------------------------------------------------------

Stealing review because Honza is OOO this week.
Attachment #671349 - Flags: review?(honzab.moz) → review+
https://hg.mozilla.org/mozilla-central/rev/6e0ef3f66290
Status: NEW → RESOLVED
Closed: 7 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.