Initialize variable that is detected as 'maybe uninitialized'.

With gcc (tested versions: 11.3.0, 12.2.0) compiled with asan, the
`type_id` variable is warned about maybe being used uninitialized in
the later call:

```
 ptr = ParseFieldMaybeLazily(static_cast<uint64_t(type_id) * 8 + 2, ptr,
                             extendee, metadata, ctx);
```

This change initializes the variable to a defined default.

PiperOrigin-RevId: 507883964
pull/11843/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 41336a0c35
commit f58d0b56e3
  1. 2
      src/google/protobuf/extension_set_inl.h

@ -206,7 +206,7 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
const char* ptr, const Msg* extendee, internal::InternalMetadata* metadata,
internal::ParseContext* ctx) {
std::string payload;
uint32_t type_id;
uint32_t type_id = 0;
enum class State { kNoTag, kHasType, kHasPayload, kDone };
State state = State::kNoTag;

Loading…
Cancel
Save