core: fix issues reported by coverity
This commit is contained in:
@@ -338,18 +338,23 @@ public class RegionMaker {
|
||||
InstructionRemover.unbindInsn(mth, exitInsn);
|
||||
}
|
||||
|
||||
block = getNextBlock(block);
|
||||
BlockNode body = getNextBlock(block);
|
||||
if (body == null) {
|
||||
mth.add(AFlag.INCONSISTENT_CODE);
|
||||
LOG.warn("Unexpected end of synchronized block");
|
||||
return null;
|
||||
}
|
||||
BlockNode exit;
|
||||
if (exits.size() == 1) {
|
||||
exit = getNextBlock(exits.iterator().next());
|
||||
} else {
|
||||
cacheSet.clear();
|
||||
exit = traverseMonitorExitsCross(block, exits, cacheSet);
|
||||
exit = traverseMonitorExitsCross(body, exits, cacheSet);
|
||||
}
|
||||
|
||||
stack.push(synchRegion);
|
||||
stack.addExit(exit);
|
||||
synchRegion.getSubBlocks().add(makeRegion(block, stack));
|
||||
synchRegion.getSubBlocks().add(makeRegion(body, stack));
|
||||
stack.pop();
|
||||
return exit;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,18 @@ public class AsmUtils {
|
||||
}
|
||||
|
||||
public static String getNameFromClassFile(File file) throws IOException {
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
ClassReader classReader = new ClassReader(in);
|
||||
return classReader.getClassName();
|
||||
String className = null;
|
||||
FileInputStream in = null;
|
||||
try {
|
||||
in = new FileInputStream(file);
|
||||
ClassReader classReader = new ClassReader(in);
|
||||
className = classReader.getClassName();
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
return className;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,12 +102,24 @@ public class InputFile {
|
||||
private static Dex loadFromClassFile(File file) throws IOException, DecodeException {
|
||||
File outFile = File.createTempFile("jadx-tmp-", System.nanoTime() + ".jar");
|
||||
outFile.deleteOnExit();
|
||||
FileOutputStream out = new FileOutputStream(outFile);
|
||||
JarOutputStream jo = new JarOutputStream(out);
|
||||
String clsName = AsmUtils.getNameFromClassFile(file);
|
||||
FileUtils.addFileToJar(jo, file, clsName + ".class");
|
||||
jo.close();
|
||||
out.close();
|
||||
FileOutputStream out = null;
|
||||
JarOutputStream jo = null;
|
||||
try {
|
||||
out = new FileOutputStream(outFile);
|
||||
jo = new JarOutputStream(out);
|
||||
String clsName = AsmUtils.getNameFromClassFile(file);
|
||||
if (clsName == null) {
|
||||
throw new IOException("Can't read class name from file: " + file);
|
||||
}
|
||||
FileUtils.addFileToJar(jo, file, clsName + ".class");
|
||||
} finally {
|
||||
if (jo != null) {
|
||||
jo.close();
|
||||
}
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
return loadFromJar(outFile);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user