[Openmp-commits] [PATCH] D26318: Added check for malloc return
Victor Campos via Openmp-commits
openmp-commits at lists.llvm.org
Fri Nov 4 17:04:43 PDT 2016
vhscampos created this revision.
vhscampos added reviewers: jcownie, jlpeyton, sfantao.
vhscampos added a subscriber: openmp-commits.
This malloc() didn't have a check for successfully allocated memory. I created one following other examples.
https://reviews.llvm.org/D26318
Files:
runtime/src/kmp_i18n.c
Index: runtime/src/kmp_i18n.c
===================================================================
--- runtime/src/kmp_i18n.c
+++ runtime/src/kmp_i18n.c
@@ -824,8 +824,10 @@
// XSI version of strerror_r.
int size = 2048;
- // TODO: Add checking result of malloc().
char * buffer = (char *) KMP_INTERNAL_MALLOC( size );
+ if (buffer == NULL) {
+ KMP_FATAL(MemoryAllocFailed);
+ }
int rc;
rc = strerror_r( err, buffer, size );
if ( rc == -1 ) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26318.76956.patch
Type: text/x-patch
Size: 576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20161105/30926e1f/attachment.bin>
More information about the Openmp-commits
mailing list