forked from OSchip/llvm-project
Added check for malloc return.
Patch by Victor Campos. Differential Revision: https://reviews.llvm.org/D26318 llvm-svn: 286441
This commit is contained in:
parent
1a33c0f242
commit
1fbb482928
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue