From 91a47123bf605c360cd329f21d3db6c9722434d5 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Sun, 5 Apr 2015 12:17:15 -0700 Subject: [PATCH] Ensure the stream is closed in DexFileFactory.loadDexFile --- .../java/org/jf/dexlib2/DexFileFactory.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DexFileFactory.java b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DexFileFactory.java index 85f8a426..a1ddee2e 100644 --- a/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DexFileFactory.java +++ b/brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DexFileFactory.java @@ -102,19 +102,22 @@ public final class DexFileFactory { } InputStream inputStream = new BufferedInputStream(new FileInputStream(dexFile)); - try { - return DexBackedDexFile.fromInputStream(opcodes, inputStream); - } catch (DexBackedDexFile.NotADexFile ex) { - // just eat it - } + try { + return DexBackedDexFile.fromInputStream(opcodes, inputStream); + } catch (DexBackedDexFile.NotADexFile ex) { + // just eat it + } - // Note: DexBackedDexFile.fromInputStream will reset inputStream back to the same position, if it fails + // Note: DexBackedDexFile.fromInputStream will reset inputStream back to the same position, if it fails - try { - return DexBackedOdexFile.fromInputStream(opcodes, inputStream); - } catch (DexBackedOdexFile.NotAnOdexFile ex) { - // just eat it + try { + return DexBackedOdexFile.fromInputStream(opcodes, inputStream); + } catch (DexBackedOdexFile.NotAnOdexFile ex) { + // just eat it + } + } finally { + inputStream.close(); } throw new ExceptionWithContext("%s is not an apk, dex file or odex file.", dexFile.getPath());