Merge pull request #3943 from bog-dan-ro/crash

Don't crash if str is null
This commit is contained in:
Wouter van Oortmerssen 2016-07-13 11:17:12 -07:00 committed by GitHub
commit 7a3f1cf78e
1 changed files with 1 additions and 1 deletions

View File

@ -876,7 +876,7 @@ FLATBUFFERS_FINAL_CLASS
/// @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
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.