Close all smali files after it is finished writing to them.

This is important for instances where smali is invoked through the run method instead of
main.
This commit is contained in:
Albert Gorski 2016-09-21 09:42:20 -04:00 committed by Ben Gruver
parent 7079014a29
commit 8f6f59cc66

17
smali/src/main/java/org/jf/smali/main.java Normal file → Executable file
View File

@ -308,16 +308,15 @@ public class main {
private static boolean assembleSmaliFile(File smaliFile, DexBuilder dexBuilder, SmaliOptions options)
throws Exception {
CommonTokenStream tokens;
FileInputStream fis = null;
LexerErrorInterface lexer;
FileInputStream fis = new FileInputStream(smaliFile);
try {
fis = new FileInputStream(smaliFile);
InputStreamReader reader = new InputStreamReader(fis, "UTF-8");
lexer = new smaliFlexLexer(reader);
LexerErrorInterface lexer = new smaliFlexLexer(reader);
((smaliFlexLexer)lexer).setSourceFile(smaliFile);
tokens = new CommonTokenStream((TokenSource)lexer);
CommonTokenStream tokens = new CommonTokenStream((TokenSource)lexer);
if (options.printTokens) {
tokens.getTokens();
@ -360,8 +359,12 @@ public class main {
dexGen.setVerboseErrors(options.verboseErrors);
dexGen.setDexBuilder(dexBuilder);
dexGen.smali_file();
return dexGen.getNumberOfSyntaxErrors() == 0;
} finally {
if (fis != null) {
fis.close();
}
}
}