no longer crash on malformed protobuf message

pull/58/head
bert hubert 2019-12-28 13:47:00 +01:00
parent c08e4da70a
commit e748bd820c
1 changed files with 7 additions and 1 deletions

View File

@ -102,7 +102,13 @@ try
for(const auto& nmm: nmms) {
std::string out;
nmm.SerializeToString(&out);
try {
nmm.SerializeToString(&out);
}
catch(std::exception& e) {
cerr<<"Something went wrong during serialization, skipping: "<<e.what()<<endl;
continue;
}
std::string buf="bert";
uint16_t len = htons(out.size());
buf.append((char*)(&len), 2);