OSDN Git Service

DO NOT MERGE) ExifInterface: Close the file when an exception happens
authorSungsoo <sungsoo@google.com>
Tue, 18 Oct 2016 05:12:00 +0000 (14:12 +0900)
committergitbuildkicker <android-build@google.com>
Thu, 3 Nov 2016 20:59:59 +0000 (13:59 -0700)
Bug: 32068647, Bug: 30936376
Change-Id: I22fa2384348c890ca726d2b1632cd54e59d25a8f
(cherry picked from commit cb17930077de640411407636eebc000e2d06dd9c)

media/java/android/media/ExifInterface.java

index e3beb4a..2c7160f 100644 (file)
@@ -1335,8 +1335,9 @@ public class ExifInterface {
         for (int i = 0; i < EXIF_TAGS.length; ++i) {
             mAttributes[i] = new HashMap();
         }
+        InputStream in = null;
         try {
-            InputStream in = new FileInputStream(mFilename);
+            in = new FileInputStream(mFilename);
             getJpegAttributes(in);
             mIsSupportedFile = true;
         } catch (IOException e) {
@@ -1349,6 +1350,7 @@ public class ExifInterface {
             if (DEBUG) {
                 printAttributes();
             }
+            IoUtils.closeQuietly(in);
         }
     }