diff --git a/include/openmc/hdf5_interface.h b/include/openmc/hdf5_interface.h index 0fe55d170..4bcef7ede 100644 --- a/include/openmc/hdf5_interface.h +++ b/include/openmc/hdf5_interface.h @@ -247,11 +247,11 @@ inline void read_dataset( { // Create buffer to read data into auto n = dataset_typesize(obj_id, name); - char* buffer = new char[n]; + std::vector buffer(n, '\0'); // Read attribute and set string - read_string(obj_id, name, n, buffer, indep); - str = std::string {buffer, n}; + read_string(obj_id, name, n, buffer.data(), indep); + str = std::string { buffer.begin(), buffer.end() }; } // array version