Changed use of strncpy to memcpy

This commit is contained in:
Phil Nash 2017-08-15 23:47:52 +01:00
parent 699e571400
commit a36395e2ff
1 changed files with 2 additions and 4 deletions

View File

@ -7,11 +7,9 @@
#include "catch_stringref.h" #include "catch_stringref.h"
#include <cstring>
#include <ostream> #include <ostream>
#include <cassert> #include <cassert>
#include <cstring>
#define _CRT_SECURE_NO_WARNINGS // Suppress warnings from MSVC about strncpy not being secure
namespace Catch { namespace Catch {
@ -95,7 +93,7 @@ namespace Catch {
void StringRef::takeOwnership() { void StringRef::takeOwnership() {
if( !isOwned() ) { if( !isOwned() ) {
m_data = new char[m_size+1]; m_data = new char[m_size+1];
strncpy( m_data, m_start, m_size ); memcpy( m_data, m_start, m_size );
m_data[m_size] = '\0'; m_data[m_size] = '\0';
m_start = m_data; m_start = m_data;
} }