From 66e101a0ffb49df3c34f14e8669856381ce8d23d Mon Sep 17 00:00:00 2001 From: Divya Shikre Date: Tue, 25 Jan 2022 19:50:57 -0500 Subject: [PATCH] Add fix to check for vector size while reading pp_dpm_pcie pop_back() was causing a seg fault when pp_dpm_pcie file is empty and returns whitespace. Signed-off-by: Divya Shikre Change-Id: I888f1f79751cd456e43751a5b96d08560a039677 (cherry picked from commit ec71380e1ce7892957c595b4bf4c6409617bbba2) --- src/rocm_smi_device.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rocm_smi_device.cc b/src/rocm_smi_device.cc index 51e67822..a80fcd31 100755 --- a/src/rocm_smi_device.cc +++ b/src/rocm_smi_device.cc @@ -630,7 +630,7 @@ int Device::writeDevInfoStr(DevInfoTypes type, std::string valStr) { ret = RSMI_STATUS_NOT_SUPPORTED; } fs.close(); - + return ret; } @@ -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;