Bug in Atribute::read() in HDF5 1.8?


It appears to me that the C++ Attribute::read() method in HDF5 1.8 can
only read variable string attributes but crashes for the fixed size
string values. The problem appears to be that the buffer for fixed
size values needs to be allocated before doing the read - and this not
being done in read()'s implementation. Here's my version of the method
that seems to work:

void Attribute::read( const DataType& mem_type, H5std_string& strg ) const
      char *strg_C;
      herr_t ret_value;
      void *buf;
      if (!mem_type.isVariableStr()) {
        size_t size = mem_type.getSize();
        strg_C = new char[size+1]; // temporary C-string for C API
        buf = strg_C;
      } else {
          buf = &strg_C;
      // call C API to get the attribute string of chars
      ret_value = H5Aread( id, mem_type.getId(), buf);
      if( ret_value < 0 )
              throw AttributeIException("Attribute::read", "H5Aread failed");
      strg = strg_C; // get 'string' from the C char*


Has anyone else run into this?



This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.