Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRené Purrio2018-01-15 03:51:25 -0500
committerAlexander Kurtakov2018-01-15 05:16:04 -0500
commit7d3d5990c8682cd4a23cc9bcc13b03a0ead238c4 (patch)
tree9a784384cc991c49a106054e4bffb8800a5fb08c
parent2e109c9ba829546ec5c0bed09bb604436ac30fd3 (diff)
downloadeclipse.platform.swt-7d3d5990c8682cd4a23cc9bcc13b03a0ead238c4.tar.gz
eclipse.platform.swt-7d3d5990c8682cd4a23cc9bcc13b03a0ead238c4.tar.xz
eclipse.platform.swt-7d3d5990c8682cd4a23cc9bcc13b03a0ead238c4.zip
Bug 529675 - [sonar] Resolve "Possible null pointer dereference"
Change-Id: I4b178bf17231e26b678c86f543fc447b1ac3ceb1 Signed-off-by: René Purrio <rpurrio@itemis.de>
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java3
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java6
-rw-r--r--bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java3
3 files changed, 12 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java
index 45c7b00ea9..8f4cc1c977 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java
@@ -96,6 +96,9 @@ String loadFile (File file) {
void loadDirectory(File file) {
String[] entries = file.list();
+ if (entries == null) {
+ entries = new String[0];
+ }
for (int i = 0; i < entries.length; i++) {
String entry = entries[i];
File f = new File(file, entry);
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
index 3aaf29bd51..8a9ed8723d 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
@@ -296,6 +296,9 @@ String[] getClassNames() {
File file = new File(path + File.separator + pkgPath);
if (file.exists()) {
String[] entries = file.list();
+ if(entries == null) {
+ entries = new String[0];
+ }
for (int i = 0; i < entries.length; i++) {
String entry = entries[i];
File f = new File(file, entry);
@@ -348,6 +351,9 @@ JNIClass[] getASTClasses() {
String packageName = getPackageName();
File dir = new File(root + "/" + packageName.replace('.', '/'));
File[] files = dir.listFiles();
+ if (files == null) {
+ files = new File[0];
+ }
for (int i = 0; i < files.length; i++) {
File file = files[i];
try {
diff --git a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
index 5a890ca792..2c9e7c2211 100644
--- a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
+++ b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
@@ -936,6 +936,9 @@ public String[] getXmls() {
String packageName = getPackageName();
File folder = new File(extrasDir != null ? extrasDir : outputDir + packageName.replace('.', '/'));
File[] files = folder.listFiles((FilenameFilter) (dir, name) -> name.endsWith("Full.bridgesupport"));
+ if(files == null) {
+ files = new File[0];
+ }
for (int i = 0; i < files.length; i++) {
array.add(files[i].getAbsolutePath());
}

Back to the top