From 05e4db63d044ee235d2fbfab8b0bb9fbdfb18315 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 30 May 2020 14:02:56 +0200 Subject: openmp: omp_alloc(0, ...) should return NULL. 2020-05-30 Jakub Jelinek * allocator.c (omp_alloc): For size == 0, return NULL early. * testsuite/libgomp.c-c++-common/alloc-4.c: New test. --- libgomp/allocator.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libgomp/allocator.c') diff --git a/libgomp/allocator.c b/libgomp/allocator.c index 8592de6..66308ab 100644 --- a/libgomp/allocator.c +++ b/libgomp/allocator.c @@ -201,6 +201,9 @@ omp_alloc (size_t size, omp_allocator_handle_t allocator) size_t alignment, new_size; void *ptr, *ret; + if (__builtin_expect (size == 0, 0)) + return NULL; + retry: if (allocator == omp_null_allocator) { -- cgit v1.1