mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
Several File.list() calls missed check for null return value. Fixed
This commit is contained in:
parent
0b4a4fb0b5
commit
026210564d
@ -2604,12 +2604,15 @@ public class Base {
|
||||
File targetDir) throws IOException {
|
||||
targetDir.mkdirs();
|
||||
String files[] = sourceDir.list();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files == null) {
|
||||
throw new IOException("Unable to list files from " + sourceDir);
|
||||
}
|
||||
for (String file : files) {
|
||||
// Ignore dot files (.DS_Store), dot folders (.svn) while copying
|
||||
if (files[i].charAt(0) == '.') continue;
|
||||
if (file.charAt(0) == '.') continue;
|
||||
//if (files[i].equals(".") || files[i].equals("..")) continue;
|
||||
File source = new File(sourceDir, files[i]);
|
||||
File target = new File(targetDir, files[i]);
|
||||
File source = new File(sourceDir, file);
|
||||
File target = new File(targetDir, file);
|
||||
if (source.isDirectory()) {
|
||||
//target.mkdirs();
|
||||
copyDir(source, target);
|
||||
|
@ -150,6 +150,9 @@ public class Archiver implements Tool {
|
||||
public void buildZip(File dir, String sofar,
|
||||
ZipOutputStream zos) throws IOException {
|
||||
String files[] = dir.list();
|
||||
if (files == null) {
|
||||
throw new IOException("Unable to list files from " + dir);
|
||||
}
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].equals(".") ||
|
||||
files[i].equals("..")) continue;
|
||||
|
@ -956,14 +956,18 @@ public class BaseNoGui {
|
||||
if (!dir.exists()) return;
|
||||
|
||||
String files[] = dir.list();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (files[i].equals(".") || files[i].equals("..")) continue;
|
||||
File dead = new File(dir, files[i]);
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String file : files) {
|
||||
if (file.equals(".") || file.equals("..")) continue;
|
||||
File dead = new File(dir, file);
|
||||
if (!dead.isDirectory()) {
|
||||
if (!PreferencesData.getBoolean("compiler.save_build_files")) {
|
||||
if (!dead.delete()) {
|
||||
// temporarily disabled
|
||||
System.err.println(I18n.format(_("Could not delete {0}"), dead));
|
||||
System.err.println(I18n.format(_("Could not delete {0}"), dead));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -95,6 +95,9 @@ public class SketchData {
|
||||
|
||||
// get list of files in the sketch folder
|
||||
String list[] = folder.list();
|
||||
if (list == null) {
|
||||
throw new IOException("Unable to list files from " + folder);
|
||||
}
|
||||
|
||||
// reset these because load() may be called after an
|
||||
// external editor event. (fix for 0099)
|
||||
|
@ -277,11 +277,13 @@ public class Compiler implements MessageConsumer {
|
||||
// used. Keep everything else, which might be reusable
|
||||
if (tempBuildFolder.exists()) {
|
||||
String files[] = tempBuildFolder.list();
|
||||
for (String file : files) {
|
||||
if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
|
||||
File deleteMe = new File(tempBuildFolder, file);
|
||||
if (!deleteMe.delete()) {
|
||||
System.err.println("Could not delete " + deleteMe);
|
||||
if (files != null) {
|
||||
for (String file : files) {
|
||||
if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
|
||||
File deleteMe = new File(tempBuildFolder, file);
|
||||
if (!deleteMe.delete()) {
|
||||
System.err.println("Could not delete " + deleteMe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user