Skip to content

Commit 200d001

Browse files
committed
Fix: make umf_ba_global_alloc(0) always return NULL
Make umf_ba_global_alloc(0) always return NULL, because it makes no sense to alloc a chunk of memory for size == 0. Ref: #371 Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
1 parent b415e78 commit 200d001

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/base_alloc/base_alloc_global.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ static void *get_original_alloc(void *user_ptr, size_t *total_size,
150150
void *umf_ba_global_aligned_alloc(size_t size, size_t alignment) {
151151
util_init_once(&ba_is_initialized, umf_ba_create_global);
152152

153+
if (size == 0) {
154+
return NULL;
155+
}
156+
153157
// for metadata
154158
size += ALLOC_METADATA_SIZE;
155159

0 commit comments

Comments
 (0)