# HG changeset patch # User morris # Date 1362535416 28800 # Node ID 872b3feace554d7dc7747a924232ed23c945ced9 # Parent 4f553e24b3b53207ca90e54f926d26f1c46f5b62 8008750: [partfait] Null pointer deference in hotspot/src/share/vm/oops/instanceKlass.hpp Summary: fix null pointer Reviewed-by: kvn, coleenp diff -r 4f553e24b3b5 -r 872b3feace55 src/share/vm/oops/instanceKlass.cpp --- a/src/share/vm/oops/instanceKlass.cpp Tue Mar 05 08:17:18 2013 -0800 +++ b/src/share/vm/oops/instanceKlass.cpp Tue Mar 05 18:03:36 2013 -0800 @@ -2170,7 +2170,11 @@ if (impl != NULL) { if (!impl->is_loader_alive(is_alive)) { // remove this guy - *adr_implementor() = NULL; + Klass** klass = adr_implementor(); + assert(klass != NULL, "null klass"); + if (klass != NULL) { + *klass = NULL; + } } } } @@ -3151,9 +3155,10 @@ if (protection_domain() != NULL) { guarantee(protection_domain()->is_oop(), "should be oop"); } - if (host_klass() != NULL) { - guarantee(host_klass()->is_metadata(), "should be in metaspace"); - guarantee(host_klass()->is_klass(), "should be klass"); + const Klass* host = host_klass(); + if (host != NULL) { + guarantee(host->is_metadata(), "should be in metaspace"); + guarantee(host->is_klass(), "should be klass"); } if (signers() != NULL) { guarantee(signers()->is_objArray(), "should be obj array"); diff -r 4f553e24b3b5 -r 872b3feace55 src/share/vm/oops/instanceKlass.hpp --- a/src/share/vm/oops/instanceKlass.hpp Tue Mar 05 08:17:18 2013 -0800 +++ b/src/share/vm/oops/instanceKlass.hpp Tue Mar 05 18:03:36 2013 -0800 @@ -536,7 +536,9 @@ assert(is_anonymous(), "not anonymous"); Klass** addr = (Klass**)adr_host_klass(); assert(addr != NULL, "no reversed space"); - *addr = host; + if (addr != NULL) { + *addr = host; + } } bool is_anonymous() const { return (_misc_flags & _misc_is_anonymous) != 0; @@ -758,7 +760,10 @@ void set_implementor(Klass* k) { assert(is_interface(), "not interface"); Klass** addr = adr_implementor(); - *addr = k; + assert(addr != NULL, "null addr"); + if (addr != NULL) { + *addr = k; + } } int nof_implementors() const {