Memory leak in hdf5_interface.h read_dataset(std::string)

This commit is contained in:
Olaf Schumann 2022-01-13 09:22:21 +01:00
parent b442a7ad1a
commit 39f0d38367

View file

@ -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<std::string::value_type> 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