Skip to content

Commit 488ee5c

Browse files
committed
handle empty proto objects
1 parent 44689c1 commit 488ee5c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

dlib/serialize.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,14 @@ namespace dlib
25702570
// read the size
25712571
in.read((char*)&size, sizeof(size));
25722572
bo.little_to_host(size);
2573-
if (!in || size == 0)
2573+
// Empty protos will just be empty.
2574+
if (size == 0)
2575+
{
2576+
item.Clear();
2577+
return;
2578+
}
2579+
2580+
if (!in)
25742581
throw dlib::serialization_error("Error while deserializing a Google Protocol Buffer object.");
25752582

25762583
// read the bytes into temp

0 commit comments

Comments
 (0)