diff --git a/opal/class/opal_object.h b/opal/class/opal_object.h index 45cb4ac0608..5d2e81fcbb1 100644 --- a/opal/class/opal_object.h +++ b/opal/class/opal_object.h @@ -479,7 +479,7 @@ static inline void opal_obj_run_destructors(opal_object_t * object) assert(NULL != object->obj_class); cls_destruct = object->obj_class->cls_destruct_array; - while( NULL != *cls_destruct ) { + while (NULL != cls_destruct && NULL != *cls_destruct) { (*cls_destruct)(object); cls_destruct++; } diff --git a/opal/mca/btl/ofi/btl_ofi_component.c b/opal/mca/btl/ofi/btl_ofi_component.c index bc4342c6423..6627b69ff28 100644 --- a/opal/mca/btl/ofi/btl_ofi_component.c +++ b/opal/mca/btl/ofi/btl_ofi_component.c @@ -675,8 +675,10 @@ static int mca_btl_ofi_init_device(struct fi_info *info) /* if the contexts have not been initiated, num_contexts should * be zero and we skip this. */ - for (int i=0; i < module->num_contexts; i++) { - mca_btl_ofi_context_finalize(&module->contexts[i], module->is_scalable_ep); + if (NULL != module->contexts) { + for (int i = 0; i < module->num_contexts; i++) { + mca_btl_ofi_context_finalize(&module->contexts[i], module->is_scalable_ep); + } } free(module->contexts);