HDFGroup / HDFGroup/hdf5

c++ H5File Constructor Error

Open
#5,191 4 comments 0 reactions 1 assignee Claimed by @bmribler View on GitHub
Component - Wrappers
Dominant language
C
Stars
988
Forks
355
Avg merge
4d 2h
Merged PRs (30d)
12

Description

When create H5File object use constructor [`H5File(const H5std_string &name, unsigned int flags, const FileAccPropList &access_plist);`](https://github.com/HDFGroup/hdf5/blob/f2642985d8c23ff7e876c6228c7cc0cf20515923/c%2B%2B/src/H5File.h#L34) may pass wrong `const char*` string to `H5Fcreate`.

The STL String default without the NULL character `\0`. So in the row [`p_get_file(name.c_str(), flags, create_plist, access_plist);`](https://github.com/HDFGroup/hdf5/blob/f2642985d8c23ff7e876c6228c7cc0cf20515923/c%2B%2B/src/H5File.cpp#L114), simply pass it by `name.c_str()` may not correct and add some characters.

The simplest way is append `\0` before call `c_str()`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.