Bug 1355661 - Continue inflating even when the Fd was closed, as long as there is still output pending. r?aklotz draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 07 Apr 2017 14:05:23 +0900
changeset 564699 09115cfdfdb92307f235815c162ecfabdff3355e
parent 563335 ce69b6e1773e9e0d0a190ce899f34b1658e66ca4
child 564700 fad717038499ef2973744f4a6a0069ba49166b4a
push id54667
push userbmo:mh+mozilla@glandium.org
push dateTue, 18 Apr 2017 21:28:48 +0000
reviewersaklotz
bugs1355661, 510844
milestone55.0a1
Bug 1355661 - Continue inflating even when the Fd was closed, as long as there is still output pending. r?aklotz This appears to have been "broken" since bug 510844, for some value of broken where it doesn't actually cause any problem in practice because of how zlib behaves. That is, in practice, we always still have input to process when there's pending output. But while that's true with zlib, that's not necessarily true for other decompressors (e.g. brotli).
modules/libjar/nsJARInputStream.cpp
--- a/modules/libjar/nsJARInputStream.cpp
+++ b/modules/libjar/nsJARInputStream.cpp
@@ -190,17 +190,17 @@ MOZ_WIN_MEM_TRY_BEGIN
 
       case MODE_CLOSED:
         return NS_BASE_STREAM_CLOSED;
 
       case MODE_DIRECTORY:
         return ReadDirectory(aBuffer, aCount, aBytesRead);
 
       case MODE_INFLATE:
-        if (mFd) {
+        if (mZs.total_out < mOutSize) {
           rv = ContinueInflate(aBuffer, aCount, aBytesRead);
         }
         // be aggressive about releasing the file!
         // note that sometimes, we will release  mFd before we've finished
         // deflating - this is because zlib buffers the input
         if (mZs.avail_in == 0) {
             mFd = nullptr;
         }