mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8353329: Small memory leak when create GrowableArray with initial size 0
Reviewed-by: jsjolen, stefank
This commit is contained in:
parent
4a50778a26
commit
b80b04d77a
@ -43,6 +43,11 @@ void* GrowableArrayArenaAllocator::allocate(int max, int element_size, Arena* ar
|
||||
|
||||
void* GrowableArrayCHeapAllocator::allocate(int max, int element_size, MemTag mem_tag) {
|
||||
assert(max >= 0, "integer overflow");
|
||||
|
||||
if (max == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t byte_size = element_size * (size_t) max;
|
||||
|
||||
// memory tag has to be specified for C heap allocation
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -811,10 +811,6 @@ class GrowableArrayCHeap : public GrowableArrayWithAllocator<E, GrowableArrayCHe
|
||||
STATIC_ASSERT(MT != mtNone);
|
||||
|
||||
static E* allocate(int max, MemTag mem_tag) {
|
||||
if (max == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (E*)GrowableArrayCHeapAllocator::allocate(max, sizeof(E), mem_tag);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user