We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 710ff57 + 8c493a8 commit 0edb311Copy full SHA for 0edb311
opal/runtime/opal_init_core.c
@@ -337,6 +337,7 @@ int opal_init_gethostname(void)
337
size_t count, length = OPAL_LOCAL_MAXHOSTNAMELEN;
338
int ret_val, num_tries = 0;
339
340
+ char *newbuf;
341
char *buf = calloc(1, length);
342
if (NULL == buf) {
343
return OPAL_ERR_OUT_OF_RESOURCE;
@@ -407,10 +408,12 @@ int opal_init_gethostname(void)
407
408
* the buffer and try again.
409
*/
410
length *= 2;
- buf = realloc(buf, length);
411
- if (NULL == buf) {
+ newbuf = realloc(buf, length);
412
+ if (NULL == newbuf) {
413
+ free(buf);
414
415
}
416
+ buf = newbuf;
417
} /* end while */
418
419
/* If we got here, it means that we tried too many times and are
0 commit comments