Skip to content

Commit

Permalink
8284458: CodeHeapState::aggregate() leaks blob_name
Browse files Browse the repository at this point in the history
Reviewed-by: mdoerr
Backport-of: d4a48843856e3d80a58d5a0a26dff6c4d349dca9
  • Loading branch information
zhengyu123 committed Apr 29, 2022
1 parent 73aea92 commit 234724c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/hotspot/share/code/codeHeapState.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -757,18 +757,17 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular
CodeBlob* cb = (CodeBlob*)heap->find_start(h);
cbType = get_cbType(cb); // Will check for cb == NULL and other safety things.
if (cbType != noType) {
const char* blob_name = os::strdup(cb->name());
const char* blob_name = NULL;
unsigned int nm_size = 0;
int temperature = 0;
nmethod* nm = cb->as_nmethod_or_null();
if (nm != NULL) { // no is_readable check required, nm = (nmethod*)cb.
ResourceMark rm;
Method* method = nm->method();
if (nm->is_in_use()) {
blob_name = os::strdup(method->name_and_sig_as_C_string());
}
if (nm->is_not_entrant()) {
if (nm->is_in_use() || nm->is_not_entrant()) {
blob_name = os::strdup(method->name_and_sig_as_C_string());
} else {
blob_name = os::strdup(cb->name());
}

nm_size = nm->total_size();
Expand Down Expand Up @@ -816,6 +815,8 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular
default:
break;
}
} else {
blob_name = os::strdup(cb->name());
}

//------------------------------------------
Expand Down

1 comment on commit 234724c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.