Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
8286519: Better memory handling
Browse files Browse the repository at this point in the history
Reviewed-by: yan
Backport-of: adfc2b195a84867fc2a66e00fad7f3c95693bc3b
  • Loading branch information
olivergillespie authored and Yuri Nesterenko committed Oct 18, 2022
1 parent e9b1202 commit eb999ab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/hotspot/share/runtime/os.cpp
Expand Up @@ -696,6 +696,11 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
NMT_TrackingLevel level = MemTracker::tracking_level();
size_t nmt_header_size = MemTracker::malloc_header_size(level);

// Check for overflow.
if (size + nmt_header_size < size) {
return NULL;
}

#ifndef ASSERT
const size_t alloc_size = size + nmt_header_size;
#else
Expand Down

0 comments on commit eb999ab

Please sign in to comment.