mirror of
https://github.com/revanced/smali.git
synced 2025-04-29 22:24:26 +02:00
Ensure all smali files are closed after the writing is complete
This makes sure that all smali files are closed after writing to them by surrounding the writer code with a try/finally block that closes the output stream once the writing has completed or when an exception occurs.
This commit is contained in:
parent
e75f2b230a
commit
43669ecc6e
@ -147,16 +147,14 @@ public class Smali {
|
||||
|
||||
private static boolean assembleSmaliFile(File smaliFile, DexBuilder dexBuilder, SmaliOptions options)
|
||||
throws Exception {
|
||||
CommonTokenStream tokens;
|
||||
|
||||
LexerErrorInterface lexer;
|
||||
|
||||
FileInputStream fis = new FileInputStream(smaliFile);
|
||||
FileInputStream fis = null;
|
||||
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();
|
||||
@ -201,5 +199,10 @@ public class Smali {
|
||||
dexGen.smali_file();
|
||||
|
||||
return dexGen.getNumberOfSyntaxErrors() == 0;
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
fis.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user