aboutsummaryrefslogtreecommitdiff
path: root/src/mutator.cc
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2020-02-04 11:59:13 -0800
committerVitaly Buka <vitalybuka@gmail.com>2020-02-04 16:35:14 -0800
commite635fead79e692d21bcbcffeea2bf09235286aaf (patch)
tree65d3b82193f55cc0343a3d4ed2cbffe568efaa92 /src/mutator.cc
parentbcf4cd1ced759a75a0168eeea2de57ced22876bc (diff)
downloadlibprotobuf-mutator-e635fead79e692d21bcbcffeea2bf09235286aaf.tar.gz
Fix compilation issues for Google internal code
Diffstat (limited to 'src/mutator.cc')
-rw-r--r--src/mutator.cc13
1 files changed, 7 insertions, 6 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;
}
}
}