Skip to content

Commit 7b436b3

Browse files
committed
make sure pointers out are initialized
1 parent 26ea7ee commit 7b436b3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/colvarbias_abf.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,8 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool clo
912912
colvarproxy *proxy = cvm::main()->proxy;
913913

914914
// The following are local aliases for the class' unique pointers
915-
colvar_grid_count *samples_out, *z_samples_out = nullptr;
916-
colvar_grid_scalar *weights_out, *z_weights_out = nullptr;
915+
colvar_grid_count *samples_out =nullptr, *z_samples_out = nullptr;
916+
colvar_grid_scalar *weights_out = nullptr, *z_weights_out = nullptr;
917917
colvar_grid_gradient *gradients_out, *z_gradients_out, *czar_gradients_out;
918918
colvargrid_integrate *pmf_out, *czar_pmf_out;
919919

@@ -951,9 +951,9 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool clo
951951
czar_gradients_out = global_czar_gradients.get();
952952
czar_pmf_out = global_czar_pmf.get();
953953
}
954-
if (b_smoothed)
954+
if (b_smoothed && weights_out != nullptr)
955955
write_grid_to_file<colvar_grid_scalar>(weights_out, prefix + ".count", close);
956-
else
956+
else if (!b_smoothed && samples_out != nullptr)
957957
write_grid_to_file<colvar_grid_count>(samples_out, prefix + ".count", close);
958958
write_grid_to_file<colvar_grid_gradient>(gradients_out, prefix + ".grad", close);
959959

0 commit comments

Comments
 (0)