Fix c4996 strcpy (#1395)

use std::memcpy() instead of std::strcpy()
This commit is contained in:
Pavel Pimenov 2016-12-10 01:17:27 +03:00 committed by Arvid Norberg
parent e1dcf82e2a
commit d8b413c771
2 changed files with 6 additions and 3 deletions

View File

@ -80,7 +80,8 @@ namespace libtorrent { namespace aux
int const ret = int(m_storage.size());
int const len = int(std::strlen(str));
m_storage.resize(ret + len + 1);
std::strcpy(&m_storage[ret], str);
std::memcpy(&m_storage[ret], str, len);
m_storage[ret + len] = '\0';
return allocation_slot(ret);
}

View File

@ -160,9 +160,11 @@ namespace libtorrent
char* allocate_string_copy(char const* str)
{
if (str == nullptr) return nullptr;
char* tmp = static_cast<char*>(std::malloc(std::strlen(str) + 1));
int const len = int(std::strlen(str));
char* tmp = static_cast<char*>(std::malloc(len + 1));
if (tmp == nullptr) return nullptr;
std::strcpy(tmp, str);
std::memcpy(tmp, str, len);
tmp[len] = '\0';
return tmp;
}