Skip to content

Commit 01312a0

Browse files
8300821: UB: Applying non-zero offset to non-null pointer 0xfffffffffffffffe produced null pointer
Reviewed-by: kvn, thartmann
1 parent 6d30bbe commit 01312a0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/hotspot/share/asm/codeBuffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ void CodeBuffer::finalize_oop_references(const methodHandle& mh) {
523523
for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
524524
// pull code out of each section
525525
CodeSection* cs = code_section(n);
526-
if (cs->is_empty()) continue; // skip trivial section
526+
if (cs->is_empty() || !cs->has_locs()) continue; // skip trivial section
527527
RelocIterator iter(cs);
528528
while (iter.next()) {
529529
if (iter.type() == relocInfo::metadata_type) {
@@ -791,7 +791,7 @@ void CodeBuffer::relocate_code_to(CodeBuffer* dest) const {
791791
for (int n = (int) SECT_FIRST; n < (int)SECT_LIMIT; n++) {
792792
// pull code out of each section
793793
const CodeSection* cs = code_section(n);
794-
if (cs->is_empty()) continue; // skip trivial section
794+
if (cs->is_empty() || !cs->has_locs()) continue; // skip trivial section
795795
CodeSection* dest_cs = dest->code_section(n);
796796
{ // Repair the pc relative information in the code after the move
797797
RelocIterator iter(dest_cs);

src/hotspot/share/code/relocInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ void RelocIterator::initialize(CompiledMethod* nm, address begin, address limit)
149149

150150
RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) {
151151
initialize_misc();
152-
152+
assert((cs->locs_start() != nullptr) && (cs->locs_end() != nullptr) ||
153+
(cs->locs_start() == nullptr) && (cs->locs_end() == nullptr), "valid start and end pointer");
153154
_current = cs->locs_start()-1;
154155
_end = cs->locs_end();
155156
_addr = cs->start();

0 commit comments

Comments
 (0)