Skip to content

Commit

Permalink
8298852: Use of uninitialized memory in MetadataFactory::free_metadata
Browse files Browse the repository at this point in the history
Reviewed-by: coleenp, stefank, dholmes
  • Loading branch information
jcking authored and coleenp committed Dec 16, 2022
1 parent ac2fcf3 commit f4caaca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hotspot/share/memory/metadataFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ class MetadataFactory : AllStatic {
assert(!md->on_stack(), "can't deallocate things on stack");
assert(!md->is_shared(), "cannot deallocate if in shared spaces");
md->deallocate_contents(loader_data);
bool is_klass = md->is_klass();
// Call the destructor. This is currently used for MethodData which has a member
// that needs to be destructed to release resources. Most Metadata derived classes have noop
// destructors and/or cleanup using deallocate_contents.
// T is a potentially const or volatile qualified pointer. Remove any const
// or volatile so we can call the destructor of the type T points to.
using U = std::remove_cv_t<T>;
md->~U();
loader_data->metaspace_non_null()->deallocate((MetaWord*)md, size, md->is_klass());
loader_data->metaspace_non_null()->deallocate((MetaWord*)md, size, is_klass);
}
}
};
Expand Down

1 comment on commit f4caaca

@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.