diff options
Diffstat (limited to 'c++/src/H5Location.cpp')
-rw-r--r-- | c++/src/H5Location.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 915f2a9..e128303 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -363,7 +363,7 @@ H5Location::getComment(const char *name, size_t buf_size) const // If buffer size is not provided, use comment length if (tmp_len == 0) - tmp_len = comment_len; + tmp_len = static_cast<size_t>(comment_len); // Temporary buffer for char* comment char *comment_C = new char[tmp_len + 1](); @@ -2044,11 +2044,15 @@ H5Location::getObjnameByIdx(hsize_t idx) const if (name_len < 0) throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); + // The actual size is the cast value + 1 for the terminal ASCII NUL + // (unfortunate in/out type sign mismatch) + size_t actual_name_len = static_cast<size_t>(name_len) + 1; + // Create buffer for C string - char *name_C = new char[name_len + 1](); + char *name_C = new char[actual_name_len](); - name_len = - H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len + 1, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, actual_name_len, + H5P_DEFAULT); if (name_len < 0) { delete[] name_C; |