From fa41e8367954fcf954606970c2bcfe38da53e493 Mon Sep 17 00:00:00 2001 From: sssooonnnggg Date: Fri, 26 Aug 2022 07:50:17 +0800 Subject: [PATCH] [C++] Fixed crash when copying table with empty shared strings (#7477) --- include/flatbuffers/flatbuffer_builder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/flatbuffers/flatbuffer_builder.h b/include/flatbuffers/flatbuffer_builder.h index aa02f50d8..9f413971e 100644 --- a/include/flatbuffers/flatbuffer_builder.h +++ b/include/flatbuffers/flatbuffer_builder.h @@ -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 CreateSharedString(const String *str) { - return CreateSharedString(str->c_str(), str->size()); + return str ? CreateSharedString(str->c_str(), str->size()) : 0; } /// @cond FLATBUFFERS_INTERNAL