Mercurial > hg > truffle
changeset 8693:872b3feace55
8008750: [partfait] Null pointer deference in hotspot/src/share/vm/oops/instanceKlass.hpp
Summary: fix null pointer
Reviewed-by: kvn, coleenp
author | morris |
---|---|
date | Tue, 05 Mar 2013 18:03:36 -0800 |
parents | 4f553e24b3b5 |
children | 8651f608fea4 |
files | src/share/vm/oops/instanceKlass.cpp src/share/vm/oops/instanceKlass.hpp |
diffstat | 2 files changed, 16 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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");
--- 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 {