summaryrefslogtreecommitdiffstats
path: root/openmp
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2016-06-21 15:39:08 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2016-06-21 15:39:08 +0000
commit5a276c45c2220a465528df46c6d1cc6d5fa403b2 (patch)
treea5ed19d24828f0977a4e0af7223b4f0f2a84ee8d /openmp
parent552d44948221d6b219ec142fd8460f4bdf108a21 (diff)
downloadbcm5719-llvm-5a276c45c2220a465528df46c6d1cc6d5fa403b2.tar.gz
bcm5719-llvm-5a276c45c2220a465528df46c6d1cc6d5fa403b2.zip
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
Diffstat (limited to 'openmp')
-rw-r--r--openmp/runtime/src/kmp_stub.c10
1 files changed, 7 insertions, 3 deletions
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 ); }
OpenPOWER on IntegriCloud