Potential fix for code scanning alert no. 24: Use of potentially dangerous function (#220)

* Potential fix for code scanning alert no. 24: Use of potentially dangerous function

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* clang-format fix

* use std::localtime_r instead of localtime.

Co-authored-by: Madsen, Jonathan <Jonathan.Madsen@amd.com>

* localtime_r is defined in global namespace.

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Kandula, Venkateshwar reddy <Venkateshwarreddy.Kandula@amd.com>
Co-authored-by: Madsen, Jonathan <Jonathan.Madsen@amd.com>
Este commit está contenido en:
Bhardwaj, Gopesh
2025-03-21 14:21:49 +05:30
cometido por GitHub
padre f27f76716e
commit c06feccf2a
+3 -1
Ver fichero
@@ -68,7 +68,9 @@ get_local_datetime(const std::string& dt_format, std::time_t*& _dt_curr)
char mbstr[strsize] = {};
memset(mbstr, '\0', sizeof(mbstr) * sizeof(char));
if(std::strftime(mbstr, sizeof(mbstr) - 1, dt_format.c_str(), std::localtime(_dt_curr)) != 0)
struct tm tm_struct;
if(std::strftime(
mbstr, sizeof(mbstr) - 1, dt_format.c_str(), localtime_r(_dt_curr, &tm_struct)) != 0)
return new std::string{mbstr};
return nullptr;