mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +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 {
|
File targetDir) throws IOException {
|
||||||
targetDir.mkdirs();
|
targetDir.mkdirs();
|
||||||
String files[] = sourceDir.list();
|
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
|
// 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;
|
//if (files[i].equals(".") || files[i].equals("..")) continue;
|
||||||
File source = new File(sourceDir, files[i]);
|
File source = new File(sourceDir, file);
|
||||||
File target = new File(targetDir, files[i]);
|
File target = new File(targetDir, file);
|
||||||
if (source.isDirectory()) {
|
if (source.isDirectory()) {
|
||||||
//target.mkdirs();
|
//target.mkdirs();
|
||||||
copyDir(source, target);
|
copyDir(source, target);
|
||||||
|
@ -150,6 +150,9 @@ public class Archiver implements Tool {
|
|||||||
public void buildZip(File dir, String sofar,
|
public void buildZip(File dir, String sofar,
|
||||||
ZipOutputStream zos) throws IOException {
|
ZipOutputStream zos) throws IOException {
|
||||||
String files[] = dir.list();
|
String files[] = dir.list();
|
||||||
|
if (files == null) {
|
||||||
|
throw new IOException("Unable to list files from " + dir);
|
||||||
|
}
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (int i = 0; i < files.length; i++) {
|
||||||
if (files[i].equals(".") ||
|
if (files[i].equals(".") ||
|
||||||
files[i].equals("..")) continue;
|
files[i].equals("..")) continue;
|
||||||
|
@ -956,9 +956,13 @@ public class BaseNoGui {
|
|||||||
if (!dir.exists()) return;
|
if (!dir.exists()) return;
|
||||||
|
|
||||||
String files[] = dir.list();
|
String files[] = dir.list();
|
||||||
for (int i = 0; i < files.length; i++) {
|
if (files == null) {
|
||||||
if (files[i].equals(".") || files[i].equals("..")) continue;
|
return;
|
||||||
File dead = new File(dir, files[i]);
|
}
|
||||||
|
|
||||||
|
for (String file : files) {
|
||||||
|
if (file.equals(".") || file.equals("..")) continue;
|
||||||
|
File dead = new File(dir, file);
|
||||||
if (!dead.isDirectory()) {
|
if (!dead.isDirectory()) {
|
||||||
if (!PreferencesData.getBoolean("compiler.save_build_files")) {
|
if (!PreferencesData.getBoolean("compiler.save_build_files")) {
|
||||||
if (!dead.delete()) {
|
if (!dead.delete()) {
|
||||||
|
@ -95,6 +95,9 @@ public class SketchData {
|
|||||||
|
|
||||||
// get list of files in the sketch folder
|
// get list of files in the sketch folder
|
||||||
String list[] = folder.list();
|
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
|
// reset these because load() may be called after an
|
||||||
// external editor event. (fix for 0099)
|
// external editor event. (fix for 0099)
|
||||||
|
@ -277,6 +277,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
// used. Keep everything else, which might be reusable
|
// used. Keep everything else, which might be reusable
|
||||||
if (tempBuildFolder.exists()) {
|
if (tempBuildFolder.exists()) {
|
||||||
String files[] = tempBuildFolder.list();
|
String files[] = tempBuildFolder.list();
|
||||||
|
if (files != null) {
|
||||||
for (String file : files) {
|
for (String file : files) {
|
||||||
if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
|
if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
|
||||||
File deleteMe = new File(tempBuildFolder, file);
|
File deleteMe = new File(tempBuildFolder, file);
|
||||||
@ -287,6 +288,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create a fresh applet folder (needed before preproc is run below)
|
// Create a fresh applet folder (needed before preproc is run below)
|
||||||
//tempBuildFolder.mkdirs();
|
//tempBuildFolder.mkdirs();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user