Skip to content

Commit

Permalink
Fix unreachable code return in a case label that has a switch with on…
Browse files Browse the repository at this point in the history
…ly a default case in it, which returns already (protocolbuffers#8927)
  • Loading branch information
Sil3ntStorm authored Sep 1, 2021
1 parent 4368383 commit 7b9b7fe
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/google/protobuf/generated_message_reflection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2491,18 +2491,12 @@ bool Reflection::HasBit(const Message& message,
// (which uses HasField()) needs to be consistent with this.
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_STRING:
switch (field->options().ctype()) {
default: {
if (IsInlined(field)) {
return !GetField<InlinedStringField>(message, field)
.GetNoArena()
.empty();
}

return GetField<ArenaStringPtr>(message, field).Get().size() > 0;
}
if (IsInlined(field)) {
return !GetField<InlinedStringField>(message, field)
.GetNoArena()
.empty();
}
return false;
return GetField<ArenaStringPtr>(message, field).Get().size() > 0;
case FieldDescriptor::CPPTYPE_BOOL:
return GetRaw<bool>(message, field) != false;
case FieldDescriptor::CPPTYPE_INT32:
Expand Down

0 comments on commit 7b9b7fe

Please sign in to comment.