From 488ee5c59ead73a44c4906a62c28ea3074f792df Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 6 Oct 2024 12:57:24 -0400 Subject: [PATCH] handle empty proto objects --- dlib/serialize.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dlib/serialize.h b/dlib/serialize.h index 6816367871..17004ef027 100644 --- a/dlib/serialize.h +++ b/dlib/serialize.h @@ -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