Skip to content

Commit db2d37a

Browse files
committed
correctly free some arrays in case of an error. This fixes a whole bunch of coverty warnings.
1 parent b4fcd38 commit db2d37a

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

ompi/mca/fcoll/dynamic/fcoll_dynamic_file_read_all.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,16 @@
851851
#endif
852852

853853
exit:
854+
if (!(fh->f_flags & OMPIO_CONTIGUOUS_MEMORY)) {
855+
if (NULL != receive_buf) {
856+
free (receive_buf);
857+
receive_buf = NULL;
858+
}
859+
}
860+
if (NULL != global_buf) {
861+
free (global_buf);
862+
global_buf = NULL;
863+
}
854864
if (NULL != sorted) {
855865
free (sorted);
856866
sorted = NULL;
@@ -878,6 +888,26 @@
878888
}
879889
if (fh->f_procs_in_group[fh->f_aggregator_index] == fh->f_rank) {
880890

891+
if (NULL != sorted_file_offsets){
892+
free(sorted_file_offsets);
893+
sorted_file_offsets = NULL;
894+
}
895+
if (NULL != file_offsets_for_agg){
896+
free(file_offsets_for_agg);
897+
file_offsets_for_agg = NULL;
898+
}
899+
if (NULL != memory_displacements){
900+
free(memory_displacements);
901+
memory_displacements= NULL;
902+
}
903+
if (NULL != sendtype){
904+
for (i = 0; i < fh->f_procs_per_group; i++) {
905+
ompi_datatype_destroy(sendtype+i);
906+
}
907+
free(sendtype);
908+
sendtype=NULL;
909+
}
910+
881911
if (NULL != disp_index){
882912
free(disp_index);
883913
disp_index = NULL;

ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,26 @@ mca_fcoll_dynamic_file_write_all (mca_io_ompio_file_t *fh,
992992

993993
exit :
994994
if (fh->f_procs_in_group[fh->f_aggregator_index] == fh->f_rank) {
995+
if (NULL != sorted_file_offsets){
996+
free(sorted_file_offsets);
997+
sorted_file_offsets = NULL;
998+
}
999+
if(NULL != file_offsets_for_agg){
1000+
free(file_offsets_for_agg);
1001+
file_offsets_for_agg = NULL;
1002+
}
1003+
if (NULL != memory_displacements){
1004+
free(memory_displacements);
1005+
memory_displacements = NULL;
1006+
}
1007+
if (NULL != recvtype){
1008+
for (i =0; i< fh->f_procs_per_group; i++) {
1009+
ompi_datatype_destroy(recvtype+i);
1010+
}
1011+
free(recvtype);
1012+
recvtype=NULL;
1013+
}
1014+
9951015
if (NULL != fh->f_io_array) {
9961016
free (fh->f_io_array);
9971017
fh->f_io_array = NULL;
@@ -1033,6 +1053,16 @@ mca_fcoll_dynamic_file_write_all (mca_io_ompio_file_t *fh,
10331053

10341054
}
10351055

1056+
if (! (fh->f_flags & OMPIO_CONTIGUOUS_MEMORY)) {
1057+
if (NULL != send_buf) {
1058+
free (send_buf);
1059+
send_buf = NULL;
1060+
}
1061+
}
1062+
if (NULL != global_buf) {
1063+
free (global_buf);
1064+
global_buf = NULL;
1065+
}
10361066
if (NULL != sorted) {
10371067
free (sorted);
10381068
sorted = NULL;

0 commit comments

Comments
 (0)