Merge pull request #24316 from alexlyulkov:al/fix-caffe-read-segfault

Fixed segfault when reading Caffe model
This commit is contained in:
Alexander Smorkalov 2023-09-25 17:53:54 +03:00 committed by GitHub
commit 9942757bab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,6 +125,7 @@ public:
{
const google::protobuf::UnknownField& field = unknownFields.field(i);
CV_Assert(field.type() == google::protobuf::UnknownField::TYPE_GROUP);
CV_CheckGE(field.group().field_count(), 2, "UnknownField should have at least 2 items: name and value");
std::string fieldName = field.group().field(0).length_delimited();
std::string fieldValue = field.group().field(1).length_delimited();
params.set(fieldName, fieldValue);