From 2036b87943960a2ac03eb03a88b05a1531a0c7c1 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sun, 15 Feb 2015 14:37:16 +0100 Subject: [PATCH] Fix NetString::ReadStringFromStream() EoF case in 'object list' command refs #6109 --- lib/cli/objectlistcommand.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/cli/objectlistcommand.cpp b/lib/cli/objectlistcommand.cpp index 3efe16485..8cb346a72 100644 --- a/lib/cli/objectlistcommand.cpp +++ b/lib/cli/objectlistcommand.cpp @@ -83,8 +83,6 @@ int ObjectListCommand::Run(const boost::program_options::variables_map& vm, cons unsigned long objects_count = 0; std::map type_count; - String message; - StreamReadContext src; String name_filter, type_filter; if (vm.count("name")) @@ -94,7 +92,17 @@ int ObjectListCommand::Run(const boost::program_options::variables_map& vm, cons bool first = true; - while (NetString::ReadStringFromStream(sfp, &message, src) == StatusNewItem) { + String message; + StreamReadContext src; + for (;;) { + StreamReadStatus srs = NetString::ReadStringFromStream(sfp, &message, src); + + if (srs == StatusEof) + break; + + if (srs != StatusNewItem) + continue; + PrintObject(std::cout, first, message, type_count, name_filter, type_filter); objects_count++; } -- 2.40.0