Commit 49c10bc2 authored by BogDan Vatra's avatar BogDan Vatra

Don't crash if str is null

Is useful especially when we want to create a string from another message string that might be null.
parent df9990ac
...@@ -876,7 +876,7 @@ FLATBUFFERS_FINAL_CLASS ...@@ -876,7 +876,7 @@ FLATBUFFERS_FINAL_CLASS
/// @param[in] str A const pointer to a `String` struct to add to the buffer. /// @param[in] str A const pointer to a `String` struct to add to the buffer.
/// @return Returns the offset in the buffer where the string starts /// @return Returns the offset in the buffer where the string starts
Offset<String> CreateString(const String *str) { Offset<String> CreateString(const String *str) {
return CreateString(str->c_str(), str->Length()); return str ? CreateString(str->c_str(), str->Length()) : 0;
} }
/// @brief Store a string in the buffer, which can contain any binary data. /// @brief Store a string in the buffer, which can contain any binary data.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment