From d9e824060cd8663d51afbd8ce2a001256e1efbd8 Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Fri, 25 Jun 2021 13:31:03 -0400 Subject: [PATCH] AddressSanitizer report stack-use-after-scope Fix the stack-use-after-scope error reported by the AddressSanitizer. Bug: SWDEV-291913 Change-Id: I0ffd71af8679b8bff6c363096fafe75dffcf329e [ROCm/amdsmi commit: 8c60dbebaa9d8c421b24fd38938ae3677e491b19] --- projects/amdsmi/src/rocm_smi_monitor.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/amdsmi/src/rocm_smi_monitor.cc b/projects/amdsmi/src/rocm_smi_monitor.cc index 6b55a5b041..53659efe36 100755 --- a/projects/amdsmi/src/rocm_smi_monitor.cc +++ b/projects/amdsmi/src/rocm_smi_monitor.cc @@ -422,7 +422,8 @@ static int get_supported_sensors(std::string dir_path, std::string fn_reg_ex, if (std::regex_search(fn, match, re)) { assert(match.size() == 2); // 1 for whole match + 1 for sub-match errno = 0; - mon_val = strtoul(match.str(1).c_str(), &endptr, 10); + std::string val_str(match.str(1)); + mon_val = strtoul(val_str.c_str(), &endptr, 10); assert(errno == 0); assert(*endptr == '\0'); if (errno) {