Bug 1302189 - Release native zip only on finalize to prevent premature unmapping of referenced memory. r=kats, a=ritu
authorEugen Sawin <esawin@mozilla.com>
Wed, 05 Oct 2016 08:14:00 -0400
changeset 350573 ea1cd458ad5e45ac6c74e16a7919a5814ba89fb2
parent 350572 f79842c6d1557dfd9550baed0a1d664c978b4c36
child 350574 893bfa57607ec629c0a762d16d9e0e098fdb558e
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, ritu
bugs1302189
milestone50.0
Bug 1302189 - Release native zip only on finalize to prevent premature unmapping of referenced memory. r=kats, a=ritu
mobile/android/base/java/org/mozilla/gecko/mozglue/ByteBufferInputStream.java
mobile/android/base/java/org/mozilla/gecko/mozglue/NativeZip.java
mobile/android/base/java/org/mozilla/gecko/util/GeckoJarReader.java
--- a/mobile/android/base/java/org/mozilla/gecko/mozglue/ByteBufferInputStream.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mozglue/ByteBufferInputStream.java
@@ -21,18 +21,18 @@ class ByteBufferInputStream extends Inpu
 
     @Override
     public int available() {
         return mBuf.remaining();
     }
 
     @Override
     public void close() {
-        mBuf = null;
-        mNativeRef.release();
+        // Do nothing, we need to keep the native references around for child
+        // buffers.
     }
 
     @Override
     public int read() {
         if (!mBuf.hasRemaining() || mNativeRef.isReleased()) {
             return -1;
         }
 
--- a/mobile/android/base/java/org/mozilla/gecko/mozglue/NativeZip.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mozglue/NativeZip.java
@@ -33,20 +33,16 @@ public class NativeZip implements Native
         mInput = input;
     }
 
     @Override
     public void finalize() {
         release();
     }
 
-    public void close() {
-        release();
-    }
-
     @Override
     public void release() {
         if (mObj != 0) {
             _release(mObj);
             mObj = 0;
         }
         mInput = null;
     }
--- a/mobile/android/base/java/org/mozilla/gecko/util/GeckoJarReader.java
+++ b/mobile/android/base/java/org/mozilla/gecko/util/GeckoJarReader.java
@@ -61,19 +61,16 @@ public final class GeckoJarReader {
         } finally {
             if (inputStream != null) {
                 try {
                     inputStream.close();
                 } catch (IOException ex) {
                     Log.e(LOGTAG, "Error closing stream", ex);
                 }
             }
-            if (zip != null) {
-                zip.close();
-            }
         }
 
         return bitmap;
     }
 
     public static String getText(Context context, String url) {
         Stack<String> jarUrls = parseUrl(url);
 
@@ -92,19 +89,16 @@ public final class GeckoJarReader {
         } finally {
             if (reader != null) {
                 try {
                     reader.close();
                 } catch (IOException ex) {
                     Log.e(LOGTAG, "Error closing reader", ex);
                 }
             }
-            if (zip != null) {
-                zip.close();
-            }
         }
 
         return text;
     }
 
     private static NativeZip getZipFile(Context context, String url)
             throws IOException, URISyntaxException {
         URI fileUrl = new URI(url);