From: Andrey Churbanov Date: Thu, 10 Nov 2016 09:08:03 +0000 (+0000) Subject: Added check for malloc return. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fbb48292888e6609b481aa0b1d1f4c2928fd0e7;p=platform%2Fupstream%2Fllvm.git Added check for malloc return. Patch by Victor Campos. Differential Revision: https://reviews.llvm.org/D26318 llvm-svn: 286441 --- diff --git a/openmp/runtime/src/kmp_i18n.c b/openmp/runtime/src/kmp_i18n.c index e008d1f..46ce10b 100644 --- a/openmp/runtime/src/kmp_i18n.c +++ b/openmp/runtime/src/kmp_i18n.c @@ -827,6 +827,9 @@ sys_error( // TODO: Add checking result of malloc(). char * buffer = (char *) KMP_INTERNAL_MALLOC( size ); int rc; + if (buffer == NULL) { + KMP_FATAL(MemoryAllocFailed); + } rc = strerror_r( err, buffer, size ); if ( rc == -1 ) { rc = errno; // XSI version sets errno. @@ -835,6 +838,9 @@ sys_error( KMP_INTERNAL_FREE( buffer ); size *= 2; buffer = (char *) KMP_INTERNAL_MALLOC( size ); + if (buffer == NULL) { + KMP_FATAL(MemoryAllocFailed); + } rc = strerror_r( err, buffer, size ); if ( rc == -1 ) { rc = errno; // XSI version sets errno.