From: Augustin Degomme Date: Mon, 6 Oct 2014 12:41:37 +0000 (+0200) Subject: Fix bug in keyval delete X-Git-Tag: v3_12~766 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/21a02186f447f30e492103d22e6d467dd0e57edf Fix bug in keyval delete --- diff --git a/src/smpi/smpi_comm.c b/src/smpi/smpi_comm.c index 2e3bf4f041..4c0283725b 100644 --- a/src/smpi/smpi_comm.c +++ b/src/smpi/smpi_comm.c @@ -623,11 +623,13 @@ int smpi_comm_keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delet } int smpi_comm_keyval_free(int* keyval){ - smpi_comm_key_elem elem = xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)keyval); - if(!elem) - return MPI_ERR_ARG; char* tmpkey=xbt_malloc(INTSIZEDCHAR); sprintf(tmpkey, "%d", *keyval); + smpi_comm_key_elem elem = xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)tmpkey); + if(!elem){ + xbt_free(tmpkey); + return MPI_ERR_ARG; + } xbt_dict_remove(smpi_comm_keyvals, (const char*)tmpkey); xbt_free(elem); xbt_free(tmpkey); diff --git a/src/smpi/smpi_mpi_dt.c b/src/smpi/smpi_mpi_dt.c index c5e93f38a5..047cf91d8d 100644 --- a/src/smpi/smpi_mpi_dt.c +++ b/src/smpi/smpi_mpi_dt.c @@ -1757,11 +1757,13 @@ int smpi_type_keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delet } int smpi_type_keyval_free(int* keyval){ - smpi_type_key_elem elem = xbt_dict_get_or_null(smpi_type_keyvals, (const char*)keyval); - if(!elem) - return MPI_ERR_ARG; char* tmpkey=xbt_malloc(INTSIZEDCHAR); sprintf(tmpkey, "%d", *keyval); + smpi_type_key_elem elem = xbt_dict_get_or_null(smpi_type_keyvals, (const char*)tmpkey); + if(!elem){ + xbt_free(tmpkey); + return MPI_ERR_ARG; + } xbt_dict_remove(smpi_type_keyvals, (const char*)tmpkey); xbt_free(elem); xbt_free(tmpkey);