Fix crash found by fuzzer in descriptor.cc

PiperOrigin-RevId: 604391963
pull/15704/head
Adam Cozzette 10 months ago committed by Copybara-Service
parent bdd833f8fc
commit 3995f538ed
  1. 8
      src/google/protobuf/descriptor.cc

@ -6054,6 +6054,10 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
BUILD_ARRAY(proto, result, extension, BuildExtension, result);
BUILD_ARRAY(proto, result, reserved_range, BuildReservedRange, result);
// Copy options.
AllocateOptions(proto, result, DescriptorProto::kOptionsFieldNumber,
"google.protobuf.MessageOptions", alloc);
// Before building submessages, check recursion limit.
--recursion_depth_;
IncrementWhenDestroyed revert{recursion_depth_};
@ -6075,10 +6079,6 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto,
result->reserved_names_[i] = alloc.AllocateStrings(proto.reserved_name(i));
}
// Copy options.
AllocateOptions(proto, result, DescriptorProto::kOptionsFieldNumber,
"google.protobuf.MessageOptions", alloc);
AddSymbol(result->full_name(), parent, result->name(), proto, Symbol(result));
for (int i = 0; i < proto.reserved_range_size(); i++) {

Loading…
Cancel
Save