Added check for malloc return.

Patch by Victor Campos.

Differential Revision: https://reviews.llvm.org/D26318

llvm-svn: 286441
This commit is contained in:
Andrey Churbanov 2016-11-10 09:08:03 +00:00
parent 1a33c0f242
commit 1fbb482928
1 changed files with 6 additions and 0 deletions

View File

@ -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.