mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 02:52:02 +00:00
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.
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user