Skip to content

Commit

Permalink
Fix: add missing stream closing on manifest disassemble (#3634)
Browse files Browse the repository at this point in the history
* add missing stream closing

* replace custom close with apache
  • Loading branch information
azotzot authored Jul 8, 2024
1 parent 71748d6 commit 1542fd0
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import brut.directory.Directory;
import brut.directory.DirectoryException;
import brut.directory.FileDirectory;
import org.apache.commons.io.IOUtils;
import org.xmlpull.v1.XmlSerializer;

import java.io.*;
Expand Down Expand Up @@ -77,6 +78,8 @@ public void decodeManifest(File outDir) throws AndrolibException {
XmlPullStreamDecoder fileDecoder = new XmlPullStreamDecoder(axmlParser, getResXmlSerializer());

Directory inApk, out;
InputStream inputStream = null;
OutputStream outputStream = null;
try {
inApk = mApkInfo.getApkFile().getDirectory();
out = new FileDirectory(outDir);
Expand All @@ -86,12 +89,15 @@ public void decodeManifest(File outDir) throws AndrolibException {
} else {
LOGGER.info("Decoding AndroidManifest.xml with only framework resources...");
}
InputStream inputStream = inApk.getFileInput("AndroidManifest.xml");
OutputStream outputStream = out.getFileOutput("AndroidManifest.xml");
inputStream = inApk.getFileInput("AndroidManifest.xml");
outputStream = out.getFileOutput("AndroidManifest.xml");
fileDecoder.decodeManifest(inputStream, outputStream);

} catch (DirectoryException ex) {
throw new AndrolibException(ex);
} finally {
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
}

if (mApkInfo.hasResources()) {
Expand Down

0 comments on commit 1542fd0

Please sign in to comment.