diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mutator.cc | 13 | ||||
-rw-r--r-- | src/mutator_test_proto2.proto | 2 | ||||
-rw-r--r-- | src/mutator_test_proto3.proto | 1 |
3 files changed, 9 insertions, 7 deletions
diff --git a/src/mutator.cc b/src/mutator.cc index c445521..6866b50 100644 --- a/src/mutator.cc +++ b/src/mutator.cc @@ -28,7 +28,7 @@ namespace protobuf_mutator { -using protobuf::Any; +using google::protobuf::Any; using protobuf::Descriptor; using protobuf::FieldDescriptor; using protobuf::FileDescriptor; @@ -367,7 +367,8 @@ using UnpackedAny = const Descriptor* GetAnyTypeDescriptor(const Any& any) { std::string type_name; - if (!Any::ParseAnyTypeUrl(any.type_url(), &type_name)) return nullptr; + if (!Any::ParseAnyTypeUrl(std::string(any.type_url()), &type_name)) + return nullptr; return any.descriptor()->file()->pool()->FindMessageTypeByName(type_name); } @@ -376,7 +377,7 @@ std::unique_ptr<Message> UnpackAny(const Any& any) { if (!desc) return {}; std::unique_ptr<Message> message( any.GetReflection()->GetMessageFactory()->GetPrototype(desc)->New()); - message->ParsePartialFromString(any.value()); + message->ParsePartialFromString(std::string(any.value())); return message; } @@ -481,9 +482,9 @@ class PostProcessing { auto It = any_.find(message); if (It != any_.end()) { Run(It->second.get(), max_depth); - // assert(GetAnyTypeDescriptor(*any) == It->second->GetDescriptor()); - // if (GetAnyTypeDescriptor(*any) != It->second->GetDescriptor()) {} - It->second->SerializePartialToString(any->mutable_value()); + std::string value; + It->second->SerializePartialToString(&value); + *any->mutable_value() = value; } } } diff --git a/src/mutator_test_proto2.proto b/src/mutator_test_proto2.proto index eb9e3c2..44d4757 100644 --- a/src/mutator_test_proto2.proto +++ b/src/mutator_test_proto2.proto @@ -1,4 +1,5 @@ syntax = "proto2"; + package protobuf_mutator; import "google/protobuf/any.proto"; @@ -130,4 +131,3 @@ message Msg { optional google.protobuf.Any any = 90; } - diff --git a/src/mutator_test_proto3.proto b/src/mutator_test_proto3.proto index f4bd3ed..f40fe2b 100644 --- a/src/mutator_test_proto3.proto +++ b/src/mutator_test_proto3.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package protobuf_mutator; import "google/protobuf/any.proto"; |