Skip to content

Commit

Permalink
handle empty proto objects
Browse files Browse the repository at this point in the history
  • Loading branch information
davisking committed Oct 6, 2024
1 parent 44689c1 commit 488ee5c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dlib/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,14 @@ namespace dlib
// read the size
in.read((char*)&size, sizeof(size));
bo.little_to_host(size);
if (!in || size == 0)
// Empty protos will just be empty.
if (size == 0)
{
item.Clear();
return;
}

if (!in)
throw dlib::serialization_error("Error while deserializing a Google Protocol Buffer object.");

// read the bytes into temp
Expand Down

0 comments on commit 488ee5c

Please sign in to comment.