From 07e37a1d22eb9eea4e1cf316d6a8600c26718fbc Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Sun, 21 Apr 2024 00:56:28 +0800 Subject: [PATCH] compatible with cxxopt. in https://github.com/jarro2783/cxxopts/blob/v3.2.1/include/cxxopts.hpp#L1011-L1018 it checks the (!in), if we read after reaching EOF, the !in will be true which results a incorrect_argument_type exception thrown. we should be very careful to avoid read after reaching eof. Signed-off-by: Xiaoxi Chen --- src/include/homeobject/homeobject.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/include/homeobject/homeobject.hpp b/src/include/homeobject/homeobject.hpp index 1b49125c..e5a6c5ff 100644 --- a/src/include/homeobject/homeobject.hpp +++ b/src/include/homeobject/homeobject.hpp @@ -22,7 +22,9 @@ struct device_info_t { friend std::istream& operator>>(std::istream& input, device_info_t& di) { std::string i_path, i_type; std::getline(input, i_path, ':'); - std::getline(input, i_type); + if (input.peek() != EOF) { + std::getline(input, i_type); + } di.path = std::filesystem::canonical(i_path); if (i_type == "HDD") { di.type = DevType::HDD;