Browse Source

Fix protobuf ubsan error when parsing empty arrays

snaury 2 years ago
parent
commit
463633625b
1 changed files with 3 additions and 1 deletions
  1. 3 1
      contrib/libs/protobuf/src/google/protobuf/parse_context.h

+ 3 - 1
contrib/libs/protobuf/src/google/protobuf/parse_context.h

@@ -234,7 +234,9 @@ class PROTOBUF_EXPORT EpsCopyInputStream {
       if (aliasing_ == kOnPatch) aliasing_ = kNoDelta;
       return flat.data();
     } else {
-      std::memcpy(buffer_, flat.data(), flat.size());
+      if (!flat.empty()) {
+        std::memcpy(buffer_, flat.data(), flat.size());
+      }
       limit_ = 0;
       limit_end_ = buffer_end_ = buffer_ + flat.size();
       next_chunk_ = nullptr;