8175345: Reported null pointer dereference defect groups

Added required explicit NULL checks

Reviewed-by: thartmann, kvn
This commit is contained in:
Rahul Raghavan 2017-03-09 00:16:51 -08:00
parent 3064b3e35d
commit b2783bb80a
4 changed files with 13 additions and 7 deletions

View file

@ -784,8 +784,8 @@ bool CallNode::may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase) {
} }
// May modify (by reflection) if an boxing object is passed // May modify (by reflection) if an boxing object is passed
// as argument or returned. // as argument or returned.
if (returns_pointer() && (proj_out(TypeFunc::Parms) != NULL)) { Node* proj = returns_pointer() ? proj_out(TypeFunc::Parms) : NULL;
Node* proj = proj_out(TypeFunc::Parms); if (proj != NULL) {
const TypeInstPtr* inst_t = phase->type(proj)->isa_instptr(); const TypeInstPtr* inst_t = phase->type(proj)->isa_instptr();
if ((inst_t != NULL) && (!inst_t->klass_is_exact() || if ((inst_t != NULL) && (!inst_t->klass_is_exact() ||
(inst_t->klass() == boxing_klass))) { (inst_t->klass() == boxing_klass))) {

View file

@ -1465,8 +1465,9 @@ Node* IfNode::dominated_by(Node* prev_dom, PhaseIterGVN *igvn) {
// be skipped. For example, range check predicate has two checks // be skipped. For example, range check predicate has two checks
// for lower and upper bounds. // for lower and upper bounds.
ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj(); ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj();
if (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL) if ((unc_proj != NULL) && (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL)) {
prev_dom = idom; prev_dom = idom;
}
// Now walk the current IfNode's projections. // Now walk the current IfNode's projections.
// Loop ends when 'this' has no more uses. // Loop ends when 'this' has no more uses.

View file

@ -3174,6 +3174,11 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) {
return false; return false;
} }
Node* exit = head->loopexit()->proj_out(0);
if (exit == NULL) {
return false;
}
#ifndef PRODUCT #ifndef PRODUCT
if (TraceLoopOpts) { if (TraceLoopOpts) {
tty->print("ArrayFill "); tty->print("ArrayFill ");
@ -3281,7 +3286,6 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) {
*/ */
// Redirect the old control and memory edges that are outside the loop. // 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 // 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 // state of the loop. It's safe in this case to replace it with the
// result_mem. // result_mem.

View file

@ -891,8 +891,9 @@ bool StringConcat::validate_control_flow() {
ctrl_path.push(cn); ctrl_path.push(cn);
ctrl_path.push(cn->proj_out(0)); ctrl_path.push(cn->proj_out(0));
ctrl_path.push(cn->proj_out(0)->unique_out()); ctrl_path.push(cn->proj_out(0)->unique_out());
if (cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0) != NULL) { Node* catchproj = cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0);
ctrl_path.push(cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0)); if (catchproj != NULL) {
ctrl_path.push(catchproj);
} }
} else { } else {
ShouldNotReachHere(); ShouldNotReachHere();