@@ -804,6 +804,7 @@ int mca_coll_han_alltoallv_using_smsc(
804804 low_gather_out = malloc (sizeof (* low_gather_out ) * low_size );
805805 struct peer_data * peers = malloc (sizeof (* peers ) * low_size );
806806 opal_datatype_t * peer_send_types = malloc (sizeof (* peer_send_types ) * low_size );
807+ int have_bufs_and_types = 0 ;
807808
808809 low_gather_in .serialization_buffer = serialization_buf ;
809810 low_gather_in .sbuf = (void * )sbuf ; // cast to discard the const
@@ -896,6 +897,7 @@ int mca_coll_han_alltoallv_using_smsc(
896897 peers [jrank ].sendtype = & peer_send_types [jrank ];
897898 }
898899
900+ have_bufs_and_types = 1 ;
899901 send_from_addrs = malloc (sizeof (* send_from_addrs )* low_size );
900902 recv_to_addrs = malloc (sizeof (* recv_to_addrs )* low_size );
901903 send_counts = malloc (sizeof (* send_counts )* low_size );
@@ -964,14 +966,16 @@ int mca_coll_han_alltoallv_using_smsc(
964966 free (recv_types );
965967 }
966968
967- for (int jlow = 0 ; jlow < low_size ; jlow ++ ) {
968- if (jlow != low_rank ) {
969- OBJ_DESTRUCT (& peer_send_types [jlow ]);
970- }
969+ if (have_bufs_and_types ) {
970+ for (int jlow = 0 ; jlow < low_size ; jlow ++ ) {
971+ if (jlow != low_rank ) {
972+ OBJ_DESTRUCT (& peer_send_types [jlow ]);
973+ }
971974
972- for (int jbuf = 0 ; jbuf < 2 ; jbuf ++ ) {
973- if (peers [jlow ].map_ctx [jbuf ]) {
974- mca_smsc -> unmap_peer_region (peers [jlow ].map_ctx [jbuf ]);
975+ for (int jbuf = 0 ; jbuf < 2 ; jbuf ++ ) {
976+ if (peers [jlow ].map_ctx [jbuf ]) {
977+ mca_smsc -> unmap_peer_region (peers [jlow ].map_ctx [jbuf ]);
978+ }
975979 }
976980 }
977981 }
0 commit comments