From 12d4280d0b4e170e98630eed93795610cf36e9f9 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 1 Nov 2011 20:22:49 +0000 Subject: [PATCH] Fix a bunch of memory leaks This commit was SVN r25411. --- ompi/tools/ompi_info/components.c | 2 ++ ompi/tools/ompi_info/output.c | 3 ++ ompi/tools/ompi_info/version.c | 52 +++++++++++++++++++------------ 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/ompi/tools/ompi_info/components.c b/ompi/tools/ompi_info/components.c index b1ac2372ae..9aa7708581 100644 --- a/ompi/tools/ompi_info/components.c +++ b/ompi/tools/ompi_info/components.c @@ -222,6 +222,7 @@ void ompi_info_open_components(void) putenv(target); free(target); } + free(env); } /* some components require the event library be active, so activate it */ @@ -834,6 +835,7 @@ void ompi_info_close_components() #if OPAL_ENABLE_FT_CR == 1 (void) opal_crs_base_close(); #endif + (void) opal_dss_close(); (void) opal_event_base_close(); /* Do not call OPAL's installdirs close; it will be handled in diff --git a/ompi/tools/ompi_info/output.c b/ompi/tools/ompi_info/output.c index bda2dbb805..bd16ac342b 100644 --- a/ompi/tools/ompi_info/output.c +++ b/ompi/tools/ompi_info/output.c @@ -186,6 +186,9 @@ void ompi_info_out(const char *pretty_message, const char *plain_message, const printf(" %s\n", value); } } + if (NULL != v) { + free(v); + } } void ompi_info_out_int(const char *pretty_message, diff --git a/ompi/tools/ompi_info/version.c b/ompi/tools/ompi_info/version.c index 72efeb27dd..f4938a785c 100644 --- a/ompi/tools/ompi_info/version.c +++ b/ompi/tools/ompi_info/version.c @@ -129,17 +129,18 @@ void ompi_info_do_version(bool want_all, opal_cmd_line_t *cmd_line) */ void ompi_info_show_ompi_version(const char *scope) { - char *tmp; + char *tmp, *tmp2; ompi_info_out("Package", "package", OPAL_PACKAGE_STRING); asprintf(&tmp, "%s:version:full", ompi_info_type_ompi); - ompi_info_out("Open MPI", tmp, - make_version_str(scope, - OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, - OMPI_RELEASE_VERSION, - OMPI_GREEK_VERSION, - OMPI_WANT_REPO_REV, OMPI_REPO_REV)); + tmp2 = make_version_str(scope, + OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION, + OMPI_RELEASE_VERSION, + OMPI_GREEK_VERSION, + OMPI_WANT_REPO_REV, OMPI_REPO_REV); + ompi_info_out("Open MPI", tmp, tmp2); free(tmp); + free(tmp2); asprintf(&tmp, "%s:version:repo", ompi_info_type_ompi); ompi_info_out("Open MPI repo revision", tmp, OMPI_REPO_REV); free(tmp); @@ -148,13 +149,14 @@ void ompi_info_show_ompi_version(const char *scope) free(tmp); asprintf(&tmp, "%s:version:full", ompi_info_type_orte); - ompi_info_out("Open RTE", tmp, - make_version_str(scope, - ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION, - ORTE_RELEASE_VERSION, - ORTE_GREEK_VERSION, - ORTE_WANT_REPO_REV, ORTE_REPO_REV)); + tmp2 = make_version_str(scope, + ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION, + ORTE_RELEASE_VERSION, + ORTE_GREEK_VERSION, + ORTE_WANT_REPO_REV, ORTE_REPO_REV); + ompi_info_out("Open RTE", tmp, tmp2); free(tmp); + free(tmp2); asprintf(&tmp, "%s:version:repo", ompi_info_type_orte); ompi_info_out("Open RTE repo revision", tmp, ORTE_REPO_REV); free(tmp); @@ -163,13 +165,14 @@ void ompi_info_show_ompi_version(const char *scope) free(tmp); asprintf(&tmp, "%s:version:full", ompi_info_type_opal); - ompi_info_out("OPAL", tmp, - make_version_str(scope, - OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, - OPAL_RELEASE_VERSION, - OPAL_GREEK_VERSION, - OPAL_WANT_REPO_REV, OPAL_REPO_REV)); + tmp2 = make_version_str(scope, + OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, + OPAL_RELEASE_VERSION, + OPAL_GREEK_VERSION, + OPAL_WANT_REPO_REV, OPAL_REPO_REV); + ompi_info_out("OPAL", tmp, tmp2); free(tmp); + free(tmp2); asprintf(&tmp, "%s:version:repo", ompi_info_type_opal); ompi_info_out("OPAL repo revision", tmp, OPAL_REPO_REV); free(tmp); @@ -293,7 +296,6 @@ static void show_mca_version(const mca_base_component_t* component, component->mca_component_minor_version, component->mca_component_release_version, "", false, ""); - if (ompi_info_pretty) { asprintf(&message, "MCA %s", component->mca_type_name); printed = false; @@ -361,6 +363,16 @@ static void show_mca_version(const mca_base_component_t* component, } free(message); } + + if (NULL != mca_version) { + free(mca_version); + } + if (NULL != api_version) { + free(api_version); + } + if (NULL != component_version) { + free(component_version); + } }