Closed Bug 367467 Opened 17 years ago Closed 17 years ago

Allow inputstream generation at the end of data in a storage stream

Categories

(Core :: XPCOM, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla1.9alpha3

People

(Reporter: Waldo, Assigned: Waldo)

References

()

Details

Attachments

(1 file, 1 obsolete file)

Attached patch Patch (obsolete) — Splinter Review
var stream = create an empty storage stream somehow...
stream.getOutputStream(0).write("foo", 3);
stream.getInputStream(3); // throws exception


The above code fails for a couple reasons: most obviously, <http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/xpcom/io/nsStorageStream.cpp&rev=&cvsroot=/cvsroot&mark=526-527#522>, and second, the uninitialization of segment buffers when the storage stream contains 0 bytes (either with no writes or with an explicit 0 write), after the first condition is changed.

This patch fixes this so that you can get an input stream for a storage stream whenever the given position is less than or equal to the amount of data in the stream -- so long as data has been written explicitly, even if the amount of data written was 0 bytes.  It does not allow a getOutputStream(0) immediately followed by a getInputStream(0), which I attempted to implement but finally abandoned as more trouble than it was worth and more than likely behavior the author would consider a bug.  (Note that there *is* a use case for writing 0 and then getting an inputstream from position 0 -- see the URL field.)
Attachment #252027 - Flags: superreview?(darin.moz)
Attachment #252027 - Flags: review?(benjamin)
Attachment #252027 - Attachment is obsolete: true
Attachment #253717 - Flags: superreview?(darin.moz)
Attachment #253717 - Flags: review?(benjamin)
Attachment #252027 - Flags: superreview?(darin.moz)
Attachment #252027 - Flags: review?(benjamin)
Attachment #253717 - Flags: superreview?(darin.moz)
Attachment #253717 - Flags: review?(benjamin)
Attachment #253717 - Flags: review+
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: mozilla1.9alpha1 → mozilla1.9alpha3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: