8175345: Reported null pointer dereference defect groups
authorrraghavan
Thu, 09 Mar 2017 00:16:51 -0800
changeset 44314 30ae899b9eca
parent 44243 bd6ac32eb679
child 44315 1e2f842b0c96
8175345: Reported null pointer dereference defect groups Summary: Added required explicit NULL checks Reviewed-by: thartmann, kvn
hotspot/src/share/vm/opto/callnode.cpp
hotspot/src/share/vm/opto/ifnode.cpp
hotspot/src/share/vm/opto/loopTransform.cpp
hotspot/src/share/vm/opto/stringopts.cpp
--- a/hotspot/src/share/vm/opto/callnode.cpp	Wed Mar 08 09:04:21 2017 -0500
+++ b/hotspot/src/share/vm/opto/callnode.cpp	Thu Mar 09 00:16:51 2017 -0800
@@ -784,8 +784,8 @@
       }
       // May modify (by reflection) if an boxing object is passed
       // as argument or returned.
-      if (returns_pointer() && (proj_out(TypeFunc::Parms) != NULL)) {
-        Node* proj = proj_out(TypeFunc::Parms);
+      Node* proj = returns_pointer() ? proj_out(TypeFunc::Parms) : NULL;
+      if (proj != NULL) {
         const TypeInstPtr* inst_t = phase->type(proj)->isa_instptr();
         if ((inst_t != NULL) && (!inst_t->klass_is_exact() ||
                                  (inst_t->klass() == boxing_klass))) {
--- a/hotspot/src/share/vm/opto/ifnode.cpp	Wed Mar 08 09:04:21 2017 -0500
+++ b/hotspot/src/share/vm/opto/ifnode.cpp	Thu Mar 09 00:16:51 2017 -0800
@@ -1465,8 +1465,9 @@
   // be skipped. For example, range check predicate has two checks
   // for lower and upper bounds.
   ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj();
-  if (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL)
-   prev_dom = idom;
+  if ((unc_proj != NULL) && (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL)) {
+    prev_dom = idom;
+  }
 
   // Now walk the current IfNode's projections.
   // Loop ends when 'this' has no more uses.
--- a/hotspot/src/share/vm/opto/loopTransform.cpp	Wed Mar 08 09:04:21 2017 -0500
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp	Thu Mar 09 00:16:51 2017 -0800
@@ -3174,6 +3174,11 @@
     return false;
   }
 
+  Node* exit = head->loopexit()->proj_out(0);
+  if (exit == NULL) {
+    return false;
+  }
+
 #ifndef PRODUCT
   if (TraceLoopOpts) {
     tty->print("ArrayFill    ");
@@ -3281,7 +3286,6 @@
 */
 
   // Redirect the old control and memory edges that are outside the loop.
-  Node* exit = head->loopexit()->proj_out(0);
   // Sometimes the memory phi of the head is used as the outgoing
   // state of the loop.  It's safe in this case to replace it with the
   // result_mem.
--- a/hotspot/src/share/vm/opto/stringopts.cpp	Wed Mar 08 09:04:21 2017 -0500
+++ b/hotspot/src/share/vm/opto/stringopts.cpp	Thu Mar 09 00:16:51 2017 -0800
@@ -891,8 +891,9 @@
       ctrl_path.push(cn);
       ctrl_path.push(cn->proj_out(0));
       ctrl_path.push(cn->proj_out(0)->unique_out());
-      if (cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0) != NULL) {
-        ctrl_path.push(cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0));
+      Node* catchproj = cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0);
+      if (catchproj != NULL) {
+        ctrl_path.push(catchproj);
       }
     } else {
       ShouldNotReachHere();