Mercurial > octave
changeset 28252:9646d752c76c stable
Fix segfault when loading a single string from an hdf5 file (bug #58268).
* ov-str-mat.cc (load_hdf5): Declare OCTAVE_LOCAL_BUFFER to be slen+1 to handle
the null termination byte. Remove FIXME questioning whether rank 0 strings
exist in HDF5 format, they do.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 28 Apr 2020 16:23:52 -0700 |
parents | 50d83252f867 |
children | 014e80a92d4f 3d6c5eb54515 |
files | libinterp/octave-value/ov-str-mat.cc |
diffstat | 1 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-str-mat.cc Fri Apr 24 13:04:08 2020 -0700 +++ b/libinterp/octave-value/ov-str-mat.cc Tue Apr 28 16:23:52 2020 -0700 @@ -680,9 +680,8 @@ } else { - // This is cruft for backward compatibility and easy data - // importation - if (rank == 0) //FIXME: Does rank==0 even exist for strings in HDF5? + // This is cruft for backward compatibility and easy data importation + if (rank == 0) { // a single string: int slen = H5Tget_size (type_hid); @@ -695,9 +694,8 @@ } else { - OCTAVE_LOCAL_BUFFER (char, s, slen); - // create datatype for (null-terminated) string - // to read into: + OCTAVE_LOCAL_BUFFER (char, s, slen+1); + // create datatype for (null-terminated) string to read into: hid_t st_id = H5Tcopy (H5T_C_S1); H5Tset_size (st_id, slen+1); if (H5Dread (data_hid, st_id, octave_H5S_ALL,