BuckPrologCompiler: Fix potential NPE
File.list() can return null, so it's unsafe to use it as an iterator in a for-loop. Store the result of File.list() first and only iterate it when it's not null. Change-Id: I0ced67e5bb5bc588433cb6a03a6283f9b31cb649
This commit is contained in:
@@ -63,7 +63,11 @@ public class BuckPrologCompiler {
|
|||||||
|
|
||||||
private static void add(JarOutputStream out, File classes, String prefix)
|
private static void add(JarOutputStream out, File classes, String prefix)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
for (String name : classes.list()) {
|
String[] list = classes.list();
|
||||||
|
if (list == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (String name : list) {
|
||||||
File f = new File(classes, name);
|
File f = new File(classes, name);
|
||||||
if (f.isDirectory()) {
|
if (f.isDirectory()) {
|
||||||
add(out, f, prefix + name + "/");
|
add(out, f, prefix + name + "/");
|
||||||
|
Reference in New Issue
Block a user