Hi,
While loading a large complex (double) variable from a MAT file,
I received the following warning from HDF5:
HDF5-DIAG: Error detected in HDF5 (1.8.17) thread 0:
000: C:\xxx\hdf5-1.8.17\src\H5Dio.c line 173 in H5Dread(): can't read data
major: Dataset
minor: Read failed
001: C:\xxx\hdf5-1.8.17\src\H5Dio.c line 446 in H5Dread(): no output buffer
major: Invalid arguments to routine
minor: Bad value
HDF5-DIAG: Error detected in HDF5 (1.8.17) thread 0:
000: C:\xxx\hdf5-1.8.17\src\H5Dio.c line 173 in H5Dread(): can't read data
major: Dataset
minor: Read failed
001: C:\xxx\hdf5-1.8.17\src\H5Dio.c line 446 in H5Dread(): no output buffer
major: Invalid arguments to routine
minor: Bad value
I tracked down the problem in mat73.c:
complex_data->Re = malloc(matvar->nbytes);
complex_data->Im = malloc(matvar->nbytes);
/* ... */
H5Dread(/* ... */, complex_data->Re);
There are multiple occurences of such kind. Please add checks to make sure both malloc calls succeed.
Thanks for this lovely library :-)
Best regards,
Felix Lelchuk
Can you share a number how many bytes you tried to allocate?
Should be fixed by f067ed1.
Great, thanks. Iirc, I was dealing with a 4x128x256x512 4-dimensional array of complex double.
I guess the second malloc could not succeed on 32-bit Windows anyway.