8180855: Null pointer dereference in OopMapSet::all_do of oopMap.cpp:394
authorzmajo
Mon, 29 May 2017 10:32:37 +0200
changeset 45327 ec60e7df88cd
parent 45326 9bf9d38e7dbe
child 45328 d17b64e3b824
child 45373 58ca160714da
child 45425 c454d65f0370
8180855: Null pointer dereference in OopMapSet::all_do of oopMap.cpp:394 Summary: Check for possible null-point dereference. Reviewed-by: kvn
hotspot/src/share/vm/compiler/oopMap.cpp
--- a/hotspot/src/share/vm/compiler/oopMap.cpp	Fri May 26 00:45:12 2017 +0000
+++ b/hotspot/src/share/vm/compiler/oopMap.cpp	Mon May 29 10:32:37 2017 +0200
@@ -350,16 +350,14 @@
         omv = oms.current();
         oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
         guarantee(loc != NULL, "missing saved register");
+        oop *derived_loc = loc;
         oop *base_loc    = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
-        oop *derived_loc = loc;
-        oop val = *base_loc;
-        if (val == (oop)NULL || Universe::is_narrow_oop_base(val)) {
-          // Ignore NULL oops and decoded NULL narrow oops which
-          // equal to Universe::narrow_oop_base when a narrow oop
-          // implicit null check is used in compiled code.
-          // The narrow_oop_base could be NULL or be the address
-          // of the page below heap depending on compressed oops mode.
-        } else {
+        // Ignore NULL oops and decoded NULL narrow oops which
+        // equal to Universe::narrow_oop_base when a narrow oop
+        // implicit null check is used in compiled code.
+        // The narrow_oop_base could be NULL or be the address
+        // of the page below heap depending on compressed oops mode.
+        if (base_loc != NULL && *base_loc != (oop)NULL && !Universe::is_narrow_oop_base(*base_loc)) {
           derived_oop_fn(base_loc, derived_loc);
         }
         oms.next();