28
28
29
29
namespace protobuf_mutator {
30
30
31
- using protobuf::Any;
31
+ using google:: protobuf::Any;
32
32
using protobuf::Descriptor;
33
33
using protobuf::FieldDescriptor;
34
34
using protobuf::FileDescriptor;
@@ -367,7 +367,8 @@ using UnpackedAny =
367
367
368
368
const Descriptor* GetAnyTypeDescriptor (const Any& any) {
369
369
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 ;
371
372
return any.descriptor ()->file ()->pool ()->FindMessageTypeByName (type_name);
372
373
}
373
374
@@ -376,7 +377,7 @@ std::unique_ptr<Message> UnpackAny(const Any& any) {
376
377
if (!desc) return {};
377
378
std::unique_ptr<Message> message (
378
379
any.GetReflection ()->GetMessageFactory ()->GetPrototype (desc)->New ());
379
- message->ParsePartialFromString (any.value ());
380
+ message->ParsePartialFromString (std::string ( any.value () ));
380
381
return message;
381
382
}
382
383
@@ -481,9 +482,9 @@ class PostProcessing {
481
482
auto It = any_.find (message);
482
483
if (It != any_.end ()) {
483
484
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 ;
487
488
}
488
489
}
489
490
}
0 commit comments