Skip to content

Commit

Permalink
Add fix to check for vector size while reading pp_dpm_pcie
Browse files Browse the repository at this point in the history
pop_back() was causing a seg fault when pp_dpm_pcie file is empty and returns whitespace.

Signed-off-by: Divya Shikre <DivyaUday.Shikre@amd.com>
Change-Id: I888f1f79751cd456e43751a5b96d08560a039677
(cherry picked from commit ec71380)
  • Loading branch information
dishikre committed Jan 28, 2022
1 parent bd3fda7 commit 66e101a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rocm_smi_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ int Device::writeDevInfoStr(DevInfoTypes type, std::string valStr) {
ret = RSMI_STATUS_NOT_SUPPORTED;
}
fs.close();

return ret;
}

Expand Down Expand Up @@ -742,7 +742,8 @@ int Device::readDevInfoMultiLineStr(DevInfoTypes type,
return 0;
}
// Remove any *trailing* empty (whitespace) lines
while (retVec->back().find_first_not_of(" \t\n\v\f\r") == std::string::npos) {
while (retVec->size() != 0 &&
retVec->back().find_first_not_of(" \t\n\v\f\r") == std::string::npos) {
retVec->pop_back();
}
return 0;
Expand Down

0 comments on commit 66e101a

Please sign in to comment.