mirror of
https://github.com/revanced/smali.git
synced 2025-04-30 06:34:25 +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)
|
private static boolean assembleSmaliFile(File smaliFile, DexBuilder dexBuilder, SmaliOptions options)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
CommonTokenStream tokens;
|
FileInputStream fis = null;
|
||||||
|
try {
|
||||||
LexerErrorInterface lexer;
|
fis = new FileInputStream(smaliFile);
|
||||||
|
|
||||||
FileInputStream fis = new FileInputStream(smaliFile);
|
|
||||||
InputStreamReader reader = new InputStreamReader(fis, "UTF-8");
|
InputStreamReader reader = new InputStreamReader(fis, "UTF-8");
|
||||||
|
|
||||||
lexer = new smaliFlexLexer(reader);
|
LexerErrorInterface lexer = new smaliFlexLexer(reader);
|
||||||
((smaliFlexLexer)lexer).setSourceFile(smaliFile);
|
((smaliFlexLexer)lexer).setSourceFile(smaliFile);
|
||||||
tokens = new CommonTokenStream((TokenSource)lexer);
|
CommonTokenStream tokens = new CommonTokenStream((TokenSource)lexer);
|
||||||
|
|
||||||
if (options.printTokens) {
|
if (options.printTokens) {
|
||||||
tokens.getTokens();
|
tokens.getTokens();
|
||||||
@ -201,5 +199,10 @@ public class Smali {
|
|||||||
dexGen.smali_file();
|
dexGen.smali_file();
|
||||||
|
|
||||||
return dexGen.getNumberOfSyntaxErrors() == 0;
|
return dexGen.getNumberOfSyntaxErrors() == 0;
|
||||||
|
} finally {
|
||||||
|
if (fis != null) {
|
||||||
|
fis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user