From e39e0026d100e99aa487c7491146222ff922a7c1 Mon Sep 17 00:00:00 2001 From: Anthony Romaniello <66272872+aromanielloNTIA@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:10:57 -0400 Subject: [PATCH] Improve safety of return status function --- src/ReturnCodes.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ReturnCodes.cpp b/src/ReturnCodes.cpp index c1a3590..4f02c47 100644 --- a/src/ReturnCodes.cpp +++ b/src/ReturnCodes.cpp @@ -56,9 +56,13 @@ std::string GetReturnStatus(int code) { * @return A status message corresponding to the input code. ******************************************************************************/ char *GetReturnStatusCharArray(const int code) { - std::string msg = GetReturnStatus(code); + const std::string msg = GetReturnStatus(code); char *c_msg = new char[msg.size() + 1]; +#ifdef _WIN32 strcpy_s(c_msg, msg.size() + 1, msg.c_str()); +#else + strcpy(c_msg, msg.c_str()); +#endif return c_msg; }