Skip to content

Commit 07e37a1

Browse files
committed
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 <[email protected]>
1 parent 7dda682 commit 07e37a1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/include/homeobject/homeobject.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ struct device_info_t {
2222
friend std::istream& operator>>(std::istream& input, device_info_t& di) {
2323
std::string i_path, i_type;
2424
std::getline(input, i_path, ':');
25-
std::getline(input, i_type);
25+
if (input.peek() != EOF) {
26+
std::getline(input, i_type);
27+
}
2628
di.path = std::filesystem::canonical(i_path);
2729
if (i_type == "HDD") {
2830
di.type = DevType::HDD;

0 commit comments

Comments
 (0)