8180565: Null pointer dereferences of ConstMethod::method()

Mon, 22 May 2017 09:14:10 +0200

author
thartmann
date
Mon, 22 May 2017 09:14:10 +0200
changeset 8768
c648545660d7
parent 8767
7b8c8cd1ee71
child 8769
cef572e3f5a6

8180565: Null pointer dereferences of ConstMethod::method()
Summary: We need to check ConstMethod::method() for NULL before dereferencing.
Reviewed-by: kvn, iignatyev

src/share/vm/oops/constMethod.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/oops/constMethod.cpp	Mon Dec 08 18:21:02 2014 +0300
     1.2 +++ b/src/share/vm/oops/constMethod.cpp	Mon May 22 09:14:10 2017 +0200
     1.3 @@ -390,8 +390,12 @@
     1.4    ResourceMark rm;
     1.5    assert(is_constMethod(), "must be constMethod");
     1.6    st->print_cr("%s", internal_name());
     1.7 -  st->print(" - method:       " INTPTR_FORMAT " ", p2i((address)method()));
     1.8 -  method()->print_value_on(st); st->cr();
     1.9 +  Method* m = method();
    1.10 +  st->print(" - method:       " INTPTR_FORMAT " ", p2i((address)m));
    1.11 +  if (m != NULL) {
    1.12 +    m->print_value_on(st);
    1.13 +  }
    1.14 +  st->cr();
    1.15    if (has_stackmap_table()) {
    1.16      st->print(" - stackmap data:       ");
    1.17      stackmap_data()->print_value_on(st);
    1.18 @@ -404,7 +408,12 @@
    1.19  void ConstMethod::print_value_on(outputStream* st) const {
    1.20    assert(is_constMethod(), "must be constMethod");
    1.21    st->print(" const part of method " );
    1.22 -  method()->print_value_on(st);
    1.23 +  Method* m = method();
    1.24 +  if (m != NULL) {
    1.25 +    m->print_value_on(st);
    1.26 +  } else {
    1.27 +    st->print("NULL");
    1.28 +  }
    1.29  }
    1.30  
    1.31  #if INCLUDE_SERVICES
    1.32 @@ -444,7 +453,7 @@
    1.33  
    1.34    // Verification can occur during oop construction before the method or
    1.35    // other fields have been initialized.
    1.36 -  guarantee(method()->is_method(), "should be method");
    1.37 +  guarantee(method() != NULL && method()->is_method(), "should be method");
    1.38  
    1.39    address m_end = (address)((intptr_t) this + size());
    1.40    address compressed_table_start = code_end();

mercurial