From 28a016b51d9cf246dc0776e623b53bda4c4fd658 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 10 May 2014 19:20:03 -0600 Subject: [PATCH] Fix potential memory issue discovered by clang's analyzer --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 72da7fc..ce1afcb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,7 +23,8 @@ char *mystrdup (const char *s) { #ifdef CHAISCRIPT_MSVC strcpy_s(d, len, s); // Copy the characters #else - strcpy(d,s); // Copy the characters + strncpy(d,s,len); // Copy the characters + d[len] = '\0'; #endif return d; // Return the new string }