From 36ee105d6a9f9c8dc8f0c7a184f8346b23e33be9 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Thu, 14 May 2009 00:21:15 +0000 Subject: [PATCH] - Fix Coverity CID #1207: set the tmp_str to NULL, so we don't have any double-free... Additionally, we should check for malloc returning NULL... This commit was SVN r21228. --- opal/runtime/opal_cr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/opal/runtime/opal_cr.c b/opal/runtime/opal_cr.c index 1deb3040a1..4a312fc5fe 100644 --- a/opal/runtime/opal_cr.c +++ b/opal/runtime/opal_cr.c @@ -765,6 +765,10 @@ static int extract_env_vars(int prev_pid) len = OPAL_PATH_MAX; tmp_str = (char *) malloc(sizeof(char) * len); + if( NULL == tmp_str) { + exit_status = OPAL_ERR_OUT_OF_RESOURCE; + goto cleanup; + } if( NULL == fgets(tmp_str, len, env_data) ) { exit_status = OPAL_ERROR; goto cleanup; @@ -777,6 +781,7 @@ static int extract_env_vars(int prev_pid) "opal_cr: extract_env_vars: Error: Parameter too long (%s)\n", tmp_str); free(tmp_str); + tmp_str = NULL; continue; }