From 44b74b296642cf00eeaa4b7d3440b6688c25f2db Mon Sep 17 00:00:00 2001 From: Arian Rezazadeh Date: Fri, 26 Feb 2021 20:22:29 +0330 Subject: [PATCH] fix visual studio unsafe error --- include/ClipboardXX.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/ClipboardXX.hpp b/include/ClipboardXX.hpp index eb6b162..7a1d719 100644 --- a/include/ClipboardXX.hpp +++ b/include/ClipboardXX.hpp @@ -59,7 +59,13 @@ class CClipboardWindows: public IClipboardOS{ throw CExceptionXX("Cannot empty clipboard!"); HGLOBAL pGlobal = GlobalAlloc(GMEM_FIXED, (Length + 1)* sizeof(char)); - strncpy((char *)pGlobal, pText, Length); + + #ifdef _MSC_VER + strcpy_s((char *)pGlobal, (Length + 1)*sizeof(char), pText); + #else + strncpy((char *)pGlobal, pText, Length); + #endif + SetClipboardData(CF_TEXT, pGlobal); GlobalFree(pGlobal);