Skip to content

Commit 62b7437

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Ignore missing descriptors in Reflection::ListFields.
This will prevent UB and crashes when lite extensions exist on full messages, which is possible when implicit_weak (force-lite) is enabled. Under normal situations we prevent such extensions. PiperOrigin-RevId: 843484856
1 parent cd76e67 commit 62b7437

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/google/protobuf/extension_set_heavy.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ void ExtensionSet::AppendToList(
6666
// AppendToList() is called.
6767

6868
if (ext.descriptor == nullptr) {
69-
output->push_back(pool->FindExtensionByNumber(extendee, number));
69+
const FieldDescriptor* field =
70+
pool->FindExtensionByNumber(extendee, number);
71+
// TODO This should be limited to and only reachable by
72+
// lite extensions on full messages.
73+
if (field != nullptr) {
74+
output->push_back(field);
75+
}
7076
} else {
7177
output->push_back(ext.descriptor);
7278
}

0 commit comments

Comments
 (0)