Skip to content

Commit e635fea

Browse files
committed
Fix compilation issues for Google internal code
1 parent bcf4cd1 commit e635fea

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/mutator.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
namespace protobuf_mutator {
3030

31-
using protobuf::Any;
31+
using google::protobuf::Any;
3232
using protobuf::Descriptor;
3333
using protobuf::FieldDescriptor;
3434
using protobuf::FileDescriptor;
@@ -367,7 +367,8 @@ using UnpackedAny =
367367

368368
const Descriptor* GetAnyTypeDescriptor(const Any& any) {
369369
std::string type_name;
370-
if (!Any::ParseAnyTypeUrl(any.type_url(), &type_name)) return nullptr;
370+
if (!Any::ParseAnyTypeUrl(std::string(any.type_url()), &type_name))
371+
return nullptr;
371372
return any.descriptor()->file()->pool()->FindMessageTypeByName(type_name);
372373
}
373374

@@ -376,7 +377,7 @@ std::unique_ptr<Message> UnpackAny(const Any& any) {
376377
if (!desc) return {};
377378
std::unique_ptr<Message> message(
378379
any.GetReflection()->GetMessageFactory()->GetPrototype(desc)->New());
379-
message->ParsePartialFromString(any.value());
380+
message->ParsePartialFromString(std::string(any.value()));
380381
return message;
381382
}
382383

@@ -481,9 +482,9 @@ class PostProcessing {
481482
auto It = any_.find(message);
482483
if (It != any_.end()) {
483484
Run(It->second.get(), max_depth);
484-
// assert(GetAnyTypeDescriptor(*any) == It->second->GetDescriptor());
485-
// if (GetAnyTypeDescriptor(*any) != It->second->GetDescriptor()) {}
486-
It->second->SerializePartialToString(any->mutable_value());
485+
std::string value;
486+
It->second->SerializePartialToString(&value);
487+
*any->mutable_value() = value;
487488
}
488489
}
489490
}

src/mutator_test_proto2.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
syntax = "proto2";
2+
23
package protobuf_mutator;
34

45
import "google/protobuf/any.proto";
@@ -130,4 +131,3 @@ message Msg {
130131
optional google.protobuf.Any any = 90;
131132
}
132133

133-

src/mutator_test_proto3.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
syntax = "proto3";
2+
23
package protobuf_mutator;
34

45
import "google/protobuf/any.proto";

0 commit comments

Comments
 (0)