From bcf3e36a48c573a81d6359a61275f477a7b57c2d Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 22 Jun 2023 11:26:39 -0700 Subject: [PATCH] Let ParseRepeatedStringOnce call AllocateFromStringBlock(). PiperOrigin-RevId: 542617650 --- src/google/protobuf/generated_message_tctable_impl.h | 4 ++-- src/google/protobuf/generated_message_tctable_lite.cc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/google/protobuf/generated_message_tctable_impl.h b/src/google/protobuf/generated_message_tctable_impl.h index b6d16b3464..84c8e309eb 100644 --- a/src/google/protobuf/generated_message_tctable_impl.h +++ b/src/google/protobuf/generated_message_tctable_impl.h @@ -808,8 +808,8 @@ class PROTOBUF_EXPORT TcParser final { static inline const char* RepeatedString(PROTOBUF_TC_PARAM_DECL); static inline const char* ParseRepeatedStringOnce( - const char* ptr, Arena* arena, SerialArena* serial_arena, - ParseContext* ctx, RepeatedPtrField& field); + const char* ptr, SerialArena* serial_arena, ParseContext* ctx, + RepeatedPtrField& field); static void AddUnknownEnum(MessageLite* msg, const TcParseTableBase* table, uint32_t tag, int32_t enum_value); diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc index 00b3eaa0b7..da19c30337 100644 --- a/src/google/protobuf/generated_message_tctable_lite.cc +++ b/src/google/protobuf/generated_message_tctable_lite.cc @@ -1684,7 +1684,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedString( field.PrepareForParse())) { do { ptr += sizeof(TagType); - ptr = ParseRepeatedStringOnce(ptr, arena, serial_arena, ctx, field); + ptr = ParseRepeatedStringOnce(ptr, serial_arena, ctx, field); if (PROTOBUF_PREDICT_FALSE(ptr == nullptr || !validate_last_string())) { PROTOBUF_MUSTTAIL return Error(PROTOBUF_TC_PARAM_NO_DATA_PASS); @@ -2273,11 +2273,11 @@ PROTOBUF_NOINLINE const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) { } PROTOBUF_ALWAYS_INLINE const char* TcParser::ParseRepeatedStringOnce( - const char* ptr, Arena* arena, SerialArena* serial_arena, ParseContext* ctx, + const char* ptr, SerialArena* serial_arena, ParseContext* ctx, RepeatedPtrField& field) { int size = ReadSize(&ptr); if (PROTOBUF_PREDICT_FALSE(!ptr)) return {}; - auto* str = Arena::Create(arena); + auto* str = new (serial_arena->AllocateFromStringBlock()) std::string(); field.AddAllocatedForParse(str); ptr = ctx->ReadString(ptr, size, str); if (PROTOBUF_PREDICT_FALSE(!ptr)) return {}; @@ -2312,7 +2312,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedString( field.PrepareForParse())) { do { ptr = ptr2; - ptr = ParseRepeatedStringOnce(ptr, arena, serial_arena, ctx, field); + ptr = ParseRepeatedStringOnce(ptr, serial_arena, ctx, field); if (PROTOBUF_PREDICT_FALSE(ptr == nullptr || !MpVerifyUtf8(field[field.size() - 1], table, entry, xform_val))) {