Skip to content

Commit ab21742

Browse files
Check for nullptr as the value
1 parent 45c9cb4 commit ab21742

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Framework/Nexus/src/NeXusFile.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,13 @@ void File::putAttr(std::string const &name, std::string const &value, bool const
788788
}
789789

790790
// this will handle string literals, which is the preferred way to pass string attributes
791-
void File::putAttr(std::string const &name, char const *const value) { putAttr(name, std::string(value)); }
791+
void File::putAttr(std::string const &name, char const *const value) {
792+
if (value == nullptr) {
793+
throw Exception("cannot write null data to attribute " + name, "putAttr", m_filename);
794+
} else {
795+
putAttr(name, std::string(value), false);
796+
}
797+
}
792798

793799
template <typename NumT>
794800
void File::putSlab(NumT const *const data, const DimSizeVector &start, const DimSizeVector &size) {

0 commit comments

Comments
 (0)