8008750: [partfait] Null pointer deference in hotspot/src/share/vm/oops/instanceKlass.hpp

Tue, 05 Mar 2013 18:03:36 -0800

author
morris
date
Tue, 05 Mar 2013 18:03:36 -0800
changeset 4693
872b3feace55
parent 4692
4f553e24b3b5
child 4694
8651f608fea4

8008750: [partfait] Null pointer deference in hotspot/src/share/vm/oops/instanceKlass.hpp
Summary: fix null pointer
Reviewed-by: kvn, coleenp

src/share/vm/oops/instanceKlass.cpp file | annotate | diff | comparison | revisions
src/share/vm/oops/instanceKlass.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/oops/instanceKlass.cpp	Tue Mar 05 08:17:18 2013 -0800
     1.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Tue Mar 05 18:03:36 2013 -0800
     1.3 @@ -2170,7 +2170,11 @@
     1.4        if (impl != NULL) {
     1.5          if (!impl->is_loader_alive(is_alive)) {
     1.6            // remove this guy
     1.7 -          *adr_implementor() = NULL;
     1.8 +          Klass** klass = adr_implementor();
     1.9 +          assert(klass != NULL, "null klass");
    1.10 +          if (klass != NULL) {
    1.11 +            *klass = NULL;
    1.12 +          }
    1.13          }
    1.14        }
    1.15      }
    1.16 @@ -3151,9 +3155,10 @@
    1.17    if (protection_domain() != NULL) {
    1.18      guarantee(protection_domain()->is_oop(), "should be oop");
    1.19    }
    1.20 -  if (host_klass() != NULL) {
    1.21 -    guarantee(host_klass()->is_metadata(), "should be in metaspace");
    1.22 -    guarantee(host_klass()->is_klass(), "should be klass");
    1.23 +  const Klass* host = host_klass();
    1.24 +  if (host != NULL) {
    1.25 +    guarantee(host->is_metadata(), "should be in metaspace");
    1.26 +    guarantee(host->is_klass(), "should be klass");
    1.27    }
    1.28    if (signers() != NULL) {
    1.29      guarantee(signers()->is_objArray(), "should be obj array");
     2.1 --- a/src/share/vm/oops/instanceKlass.hpp	Tue Mar 05 08:17:18 2013 -0800
     2.2 +++ b/src/share/vm/oops/instanceKlass.hpp	Tue Mar 05 18:03:36 2013 -0800
     2.3 @@ -536,7 +536,9 @@
     2.4      assert(is_anonymous(), "not anonymous");
     2.5      Klass** addr = (Klass**)adr_host_klass();
     2.6      assert(addr != NULL, "no reversed space");
     2.7 -    *addr = host;
     2.8 +    if (addr != NULL) {
     2.9 +      *addr = host;
    2.10 +    }
    2.11    }
    2.12    bool is_anonymous() const                {
    2.13      return (_misc_flags & _misc_is_anonymous) != 0;
    2.14 @@ -758,7 +760,10 @@
    2.15    void set_implementor(Klass* k) {
    2.16      assert(is_interface(), "not interface");
    2.17      Klass** addr = adr_implementor();
    2.18 -    *addr = k;
    2.19 +    assert(addr != NULL, "null addr");
    2.20 +    if (addr != NULL) {
    2.21 +      *addr = k;
    2.22 +    }
    2.23    }
    2.24  
    2.25    int  nof_implementors() const       {

mercurial