File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -584,7 +584,13 @@ absl::optional<std::string> PyProtoDescriptorName(py::handle py_proto) {
584584
585585bool PyProtoIsCompatible (py::handle py_proto, const Descriptor* descriptor) {
586586 assert (PyGILState_Check ());
587- assert (descriptor->file ()->pool () == DescriptorPool::generated_pool ());
587+ if (descriptor->file ()->pool () != DescriptorPool::generated_pool ()) {
588+ // / This indicates that the C++ descriptor does not come from the C++
589+ // / DescriptorPool. This may happen if the C++ code has the same proto
590+ // / in different descriptor pools, perhaps from different shared objects,
591+ // / and could be result in undefined behavior.
592+ return false ;
593+ }
588594
589595 auto py_descriptor = ResolveAttrs (py_proto, {" DESCRIPTOR" });
590596 if (!py_descriptor) {
You can’t perform that action at this time.
0 commit comments