From 5a276c45c2220a465528df46c6d1cc6d5fa403b2 Mon Sep 17 00:00:00 2001 From: Jonathan Peyton Date: Tue, 21 Jun 2016 15:39:08 +0000 Subject: Bug fix for segfault in stubs library There was a segfault in the stubs library in posix_memalign because of a bad parameter. The fix is to send address of the pointer as a parameter. Also added check of result of posix_memalign. Patch by Andrey Churbanov. Differential Revision: http://reviews.llvm.org/D21529 llvm-svn: 273276 --- openmp/runtime/src/kmp_stub.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'openmp') diff --git a/openmp/runtime/src/kmp_stub.c b/openmp/runtime/src/kmp_stub.c index 5ca9f97a641..437bf3d538a 100644 --- a/openmp/runtime/src/kmp_stub.c +++ b/openmp/runtime/src/kmp_stub.c @@ -111,9 +111,13 @@ void * kmp_aligned_malloc( size_t sz, size_t a ) { errno = ENOSYS; // not supported return NULL; // no standard aligned allocator on Windows (pre - C11) #else - void **res; - errno = posix_memalign( res, a, sz ); - return *res; + void *res; + int err; + if( err = posix_memalign( &res, a, sz ) ) { + errno = err; // can be EINVAL or ENOMEM + return NULL; + } + return res; #endif } void * kmp_calloc( size_t nelem, size_t elsize ) { i; return calloc( nelem, elsize ); } -- cgit v1.2.3