Fixing the problem with undecodeable protobuf messages (didn't properly ignore the message before)
Change-Id: I440b14e33573f91621d69c537bc6e31df6d13dd5
diff --git a/ccnx/ccnx-common.h b/ccnx/ccnx-common.h
index d1b169d..c78970b 100644
--- a/ccnx/ccnx-common.h
+++ b/ccnx/ccnx-common.h
@@ -107,7 +107,11 @@
deserializeMsg (const Bytes &bytes)
{
boost::shared_ptr<Msg> retval (new Msg ());
- retval->ParseFromArray (head (bytes), bytes.size ());
+ if (!retval->ParseFromArray (head (bytes), bytes.size ()))
+ {
+ // to indicate an error
+ return boost::shared_ptr<Msg> ();
+ }
return retval;
}
@@ -139,7 +143,11 @@
in.push(boost::make_iterator_range(sBytes)); // source
boost::shared_ptr<Msg> retval = boost::make_shared<Msg>();
- retval->ParseFromIstream(&in);
+ if (!retval->ParseFromIstream(&in))
+ {
+ // to indicate an error
+ return boost::shared_ptr<Msg> ();
+ }
return retval;
}