Skip to content

Commit

Permalink
fix out of bounds error in TpSensorDriver::read_temps
Browse files Browse the repository at this point in the history
Should fix github issue #139
  • Loading branch information
vmatare committed Aug 29, 2021
1 parent 5ebbd1f commit 6b9e348
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/drivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,14 @@ void TpSensorDriver::read_temps() const
throw IOerror(MSG_T_GET(path_), errno);

unsigned int tidx = 0;
unsigned int cidx = 0;
int tmp;
while (!(f.eof() || f.fail())) {
f >> tmp;
if (f.bad())
throw IOerror(MSG_T_GET(path_), errno);
if (!f.fail() && in_use_[tidx])
temp_state.add_temp(tmp + correction_[tidx]);
tidx++;
if (!f.fail() && in_use_[tidx++])
temp_state.add_temp(tmp + correction_[cidx++]);
}
}

Expand Down

0 comments on commit 6b9e348

Please sign in to comment.