[C++] Fixed crash when copying table with empty shared strings (#7477)

This commit is contained in:
sssooonnnggg
2022-08-26 07:50:17 +08:00
committed by GitHub
parent 799cc8f7b9
commit fa41e83679

View File

@@ -579,7 +579,7 @@ class FlatBufferBuilder {
/// @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> CreateSharedString(const String *str) {
return CreateSharedString(str->c_str(), str->size());
return str ? CreateSharedString(str->c_str(), str->size()) : 0;
}
/// @cond FLATBUFFERS_INTERNAL