ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [2/4] ant git commit: fix possible null dereferences
Date Wed, 21 Dec 2016 09:32:49 GMT
fix possible null dereferences


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/77c681c5
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/77c681c5
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/77c681c5

Branch: refs/heads/master
Commit: 77c681c5bee6dc6bd50168356f794f3d5d42f90f
Parents: e1f9674
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Wed Dec 21 10:31:44 2016 +0100
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Wed Dec 21 10:31:44 2016 +0100

----------------------------------------------------------------------
 src/main/org/apache/tools/ant/IntrospectionHelper.java         | 2 ++
 src/main/org/apache/tools/ant/taskdefs/Javadoc.java            | 6 ++++--
 src/main/org/apache/tools/ant/taskdefs/XmlProperty.java        | 6 ++++--
 .../org/apache/tools/ant/taskdefs/optional/depend/Depend.java  | 2 +-
 .../tools/ant/taskdefs/optional/jdepend/JDependTask.java       | 2 +-
 .../tools/ant/taskdefs/optional/sound/AntSoundPlayer.java      | 4 +++-
 src/main/org/apache/tools/tar/TarEntry.java                    | 2 +-
 7 files changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/77c681c5/src/main/org/apache/tools/ant/IntrospectionHelper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java
index 3008656..719f22d 100644
--- a/src/main/org/apache/tools/ant/IntrospectionHelper.java
+++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java
@@ -407,6 +407,7 @@ public final class IntrospectionHelper {
                     + " doesn't support the \"" + attributeName + "\" attribute.";
             throw new UnsupportedAttributeException(msg, attributeName);
         }
+        if (as != null) { // possible if value == null
         try {
             as.setObject(p, element, value);
         } catch (final IllegalAccessException ie) {
@@ -415,6 +416,7 @@ public final class IntrospectionHelper {
         } catch (final InvocationTargetException ite) {
             throw extractBuildException(ite);
         }
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/77c681c5/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
index f3c16ce..b7fb417 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
@@ -1772,10 +1772,12 @@ public class Javadoc extends Task {
                 useExternalFile, tmpList, srcListWriter);
 
             if (useExternalFile) {
-                srcListWriter.flush();
+                srcListWriter.flush(); //NOSONAR
             }
         } catch (final IOException e) {
-            tmpList.delete();
+            if (tmpList != null) {
+                tmpList.delete();
+            }
             throw new BuildException("Error creating temporary file",
                                      e, getLocation());
         } finally {

http://git-wip-us.apache.org/repos/asf/ant/blob/77c681c5/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java b/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
index 2830bdf..ffd89d1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
+++ b/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
@@ -384,10 +384,12 @@ public class XmlProperty extends org.apache.tools.ant.Task {
                     if (containingPath != null && nodeName.equals(PATH)) {
                         // A "path" attribute for a node within a Path object.
                         containingPath.setPath(attributeValue);
-                    } else if (container instanceof Path && nodeName.equals(REF_ID))
{
+                    } else if (containingPath != null
+                               && container instanceof Path && nodeName.equals(REF_ID))
{
                         // A "refid" attribute for a node within a Path object.
                         containingPath.setPath(attributeValue);
-                    } else if (container instanceof Path && nodeName.equals(LOCATION))
{
+                    } else if (containingPath != null && container instanceof Path
+                               && nodeName.equals(LOCATION)) {
                         // A "location" attribute for a node within a
                         // Path object.
                         containingPath.setLocation(resolveFile(attributeValue));

http://git-wip-us.apache.org/repos/asf/ant/blob/77c681c5/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
index cc65129..2cf335c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
@@ -197,7 +197,7 @@ public class Depend extends MatchingTask {
                     dependencyList = new Vector();
                     className = line.substring(prependLength);
                     dependencyMap.put(className, dependencyList);
-                } else {
+                } else if (dependencyList != null) {
                     dependencyList.addElement(line);
                 }
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/77c681c5/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
index 9d2e9ae..c608583 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
@@ -553,7 +553,7 @@ public class JDependTask extends Task {
             }
 
             jdepend.analyze();
-            if (pw.checkError()) {
+            if (pw != null && pw.checkError()) {
                 throw new IOException("Encountered an error writing JDepend"
                                       + " output");
             }

http://git-wip-us.apache.org/repos/asf/ant/blob/77c681c5/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java b/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
index f2ad686..aef214f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/sound/AntSoundPlayer.java
@@ -133,7 +133,9 @@ public class AntSoundPlayer implements LineListener, BuildListener {
                 } else {
                     playClip(audioClip, loops);
                 }
-                audioClip.drain();
+                if (audioClip != null) {
+                    audioClip.drain();
+                }
             } finally {
                 if (audioClip != null) {
                     audioClip.close();

http://git-wip-us.apache.org/repos/asf/ant/blob/77c681c5/src/main/org/apache/tools/tar/TarEntry.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarEntry.java b/src/main/org/apache/tools/tar/TarEntry.java
index de15a1c..6799079 100644
--- a/src/main/org/apache/tools/tar/TarEntry.java
+++ b/src/main/org/apache/tools/tar/TarEntry.java
@@ -333,7 +333,7 @@ public class TarEntry implements TarConstants {
      * @return True if the entries are equal.
      */
     public boolean equals(TarEntry it) {
-        return getName().equals(it.getName());
+        return it != null && getName().equals(it.getName());
     }
 
     /**


Mime
View raw message