Skip to content

Commit

Permalink
compatible with cxxopt.
Browse files Browse the repository at this point in the history
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 <xiaoxchen@ebay.com>
  • Loading branch information
xiaoxichen committed Apr 20, 2024
1 parent 7dda682 commit 07e37a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/include/homeobject/homeobject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 07e37a1

Please sign in to comment.