diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index 992b6a367d8..149c0a4fbe2 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -2378,8 +2378,7 @@ char *GHOST_SystemWin32::getClipboard(bool /*selection*/) const len = strlen(buffer); char *temp_buff = (char *)malloc(len + 1); - strncpy(temp_buff, buffer, len); - temp_buff[len] = '\0'; + memcpy(temp_buff, buffer, len + 1); /* Buffer mustn't be accessed after CloseClipboard * it would like accessing free-d memory */ diff --git a/source/blender/animrig/intern/action_test.cc b/source/blender/animrig/intern/action_test.cc index a9844a1a44d..d251dfe5d3b 100644 --- a/source/blender/animrig/intern/action_test.cc +++ b/source/blender/animrig/intern/action_test.cc @@ -1153,7 +1153,7 @@ TEST_F(ActionLayersTest, conversion_to_layered_action_groups) ASSERT_NE(rename_group, nullptr); ASSERT_STREQ(rename_group->name, "Test_Rename"); /* Forcing a duplicate name which was allowed by legacy actions. */ - strcpy(rename_group->name, "Test"); + STRNCPY_UTF8(rename_group->name, "Test"); Action *converted = convert_to_layered_action(*bmain, *action); Strip *strip = converted->layer(0)->strip(0); diff --git a/source/blender/blenlib/intern/system_win32.cc b/source/blender/blenlib/intern/system_win32.cc index 610475f0057..c3706d056dd 100644 --- a/source/blender/blenlib/intern/system_win32.cc +++ b/source/blender/blenlib/intern/system_win32.cc @@ -417,16 +417,16 @@ static void bli_windows_exception_message_get(const EXCEPTION_POINTERS *exceptio bli_windows_get_module_name(address, modulename, sizeof(modulename)); DWORD threadId = GetCurrentThreadId(); - snprintf(r_message, - 512, - "Error : %s\n" - "Address : 0x%p\n" - "Module : %s\n" - "Thread : %.8x\n", - exception_name, - address, - modulename, - threadId); + BLI_snprintf(r_message, + 512, + "Error : %s\n" + "Address : 0x%p\n" + "Module : %s\n" + "Thread : %.8x\n", + exception_name, + address, + modulename, + threadId); } /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenlib/tests/BLI_string_utf8_test.cc b/source/blender/blenlib/tests/BLI_string_utf8_test.cc index 35b1c0f01f8..2e426f490c5 100644 --- a/source/blender/blenlib/tests/BLI_string_utf8_test.cc +++ b/source/blender/blenlib/tests/BLI_string_utf8_test.cc @@ -360,7 +360,7 @@ TEST(string, StringNLenUTF8_Incomplete) #define EXPECT_BYTE_OFFSET(truncate_ofs, expect_nchars) \ { \ size_t buf_ofs = 0; \ - strcpy(buf, ref_str); \ + STRNCPY(buf, ref_str); \ buf[truncate_ofs] = '\0'; \ EXPECT_EQ(BLI_strnlen_utf8_ex(buf, ref_str_len, &buf_ofs), expect_nchars); \ EXPECT_EQ(buf_ofs, truncate_ofs); \