Skip to content

Commit

Permalink
Improve safety of return status function
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanielloNTIA committed Oct 31, 2024
1 parent e59813c commit e39e002
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ReturnCodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit e39e002

Please sign in to comment.