From 3e190414257d8c366ff39a4553fa2f37b28eba3d Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Thu, 15 May 2014 08:41:14 +0000 Subject: [PATCH] Fix memory leak in mca_common_sm_rml_info_bcast(...) The local buffer object is only used by the root of the group, so move down the buffer declaration and initialization. cmr=v1.8.2:reviewer=rhc This commit was SVN r31771. --- ompi/mca/common/sm/common_sm_rml.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ompi/mca/common/sm/common_sm_rml.c b/ompi/mca/common/sm/common_sm_rml.c index ee42caa6ef..82acf7405f 100644 --- a/ompi/mca/common/sm/common_sm_rml.c +++ b/ompi/mca/common/sm/common_sm_rml.c @@ -13,6 +13,8 @@ * Copyright (c) 2008-2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2010-2013 Los Alamos National Security, LLC. * All rights reserved. + * Copyright (c) 2014 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -71,17 +73,17 @@ mca_common_sm_rml_info_bcast(opal_shmem_ds_t *out_ds_buf, { int rc = OMPI_SUCCESS, tmprc; char *msg_id_str_to_tx = NULL; - opal_buffer_t *buffer = NULL; sm_return_t smr; - if (NULL == (buffer = OBJ_NEW(opal_buffer_t))) { - return OMPI_ERR_OUT_OF_RESOURCE; - } OBJ_CONSTRUCT(&smr.buf, opal_buffer_t); /* figure out if i am the root proc in the group. if i am, bcast the * message the rest of the local procs. */ if (proc0) { + opal_buffer_t *buffer = NULL; + if (NULL == (buffer = OBJ_NEW(opal_buffer_t))) { + return OMPI_ERR_OUT_OF_RESOURCE; + } size_t p; /* pack the data that we are going to send. first the queueing id, then * the shmem_ds buf. note that msg_id_str is used only for verifying