From e4db1fa8d6db37963790a8b58b3b5750b29d5caa Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Thu, 4 May 2017 17:53:54 -0400 Subject: [PATCH] Prevent closing objects that may not exist. --- .../apktool-cli/src/main/java/brut/apktool/Main.java | 5 ++--- .../apktool-lib/src/main/java/brut/androlib/ApkDecoder.java | 4 +++- .../src/main/java/brut/androlib/res/AndrolibResources.java | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java b/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java index 6e292713..626d2bbd 100644 --- a/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java +++ b/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java @@ -190,10 +190,9 @@ public class Main { } finally { try { decoder.close(); - } catch (IOException e) { - } + } catch (IOException ignored) {} } - + System.exit(0); } private static void cmdBuild(CommandLine cli) throws BrutException { diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java index 43c4a0d1..944faaeb 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java @@ -286,7 +286,9 @@ public class ApkDecoder { } public void close() throws IOException { - mAndrolib.close(); + if (mAndrolib != null) { + mAndrolib.close(); + } } public final static short DECODE_SOURCES_NONE = 0x0000; diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java index eebe3bbb..2b1ad0c7 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/AndrolibResources.java @@ -819,7 +819,9 @@ final public class AndrolibResources { } public void close() throws IOException { - mFramework.close(); + if (mFramework != null) { + mFramework.close(); + } } public ApkOptions apkOptions;