From bcdd3ddbde722340b6da668464d64351757b9ef7 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 12 Feb 2009 19:15:37 +0000 Subject: [PATCH] Ensure to zero out all the pointers in the op so that the destructor knows what it can and cannot free (these pointers are largely unused and therefore otherwise uninitialized in user-defined op's and MPI_REPLACE). This commit was SVN r20532. --- ompi/op/op.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ompi/op/op.c b/ompi/op/op.c index 7fe7c9d0a0..83be1631f9 100644 --- a/ompi/op/op.c +++ b/ompi/op/op.c @@ -318,12 +318,21 @@ static int add_intrinsic(ompi_op_t *op, int fort_handle, int flags, */ static void ompi_op_construct(ompi_op_t *new_op) { - int ret_val; + int i; /* assign entry in fortran <-> c translation array */ - ret_val = opal_pointer_array_add(ompi_op_f_to_c_table, new_op); - new_op->o_f_to_c_index = ret_val; + new_op->o_f_to_c_index = + opal_pointer_array_add(ompi_op_f_to_c_table, new_op); + + /* Set everything to NULL so that we can intelligently free + non-NULL's in the destructor */ + for (i = 0; i < OMPI_OP_BASE_TYPE_MAX; ++i) { + new_op->o_func.intrinsic.fns[i] = NULL; + new_op->o_func.intrinsic.modules[i] = NULL; + new_op->o_3buff_intrinsic.fns[i] = NULL; + new_op->o_3buff_intrinsic.modules[i] = NULL; + } }