summaryrefslogtreecommitdiff
path: root/Bus
diff options
context:
space:
mode:
Diffstat (limited to 'Bus')
-rw-r--r--Bus/Ivy/DataTypes.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/Bus/Ivy/DataTypes.h b/Bus/Ivy/DataTypes.h
index 190a7a6..280c2de 100644
--- a/Bus/Ivy/DataTypes.h
+++ b/Bus/Ivy/DataTypes.h
@@ -10,7 +10,7 @@
#endif
#include <string.h>
-
+#include <string>
namespace ivy
{
@@ -39,17 +39,19 @@ public:
{
if ( ptr ) delete [] ptr;
ptr = allocBuffer( len );
- strncpy( ptr, s, len );
+ strncpy_s( ptr, len + 1, s, len );
}
void erase(size_t start=0, size_t len = npos)
{
char *newptr;
size_t real_len;
+ size_t buf_size;
real_len = len == npos ? size - start : len;
if ( real_len > size ) real_len = size;
- newptr = allocBuffer( size - real_len );
- strncpy( newptr, ptr , start );
- strncpy( &newptr[start], &ptr[start+real_len], size - start );
+ buf_size = size - real_len;
+ newptr = allocBuffer( buf_size );
+ strncpy_s( newptr, buf_size +1, ptr , start );
+ strncpy_s( &newptr[start], buf_size +1 - start, &ptr[start+real_len], size - start );
delete ptr;
ptr = newptr;
}
@@ -61,10 +63,11 @@ public:
{
char *newptr;
if ( len == npos ) len = strlen(s) ;
- newptr = allocBuffer( size + len );
- strncpy( newptr , ptr, index );
- strncpy( newptr+index , s, len ) ;
- strncpy( newptr+index+len , &ptr[index], size - (index+len) ) ;
+ size_t buf_len = size + len;
+ newptr = allocBuffer( buf_len );
+ strncpy_s( newptr , buf_len +1, ptr, index );
+ strncpy_s( newptr+index, buf_len + 1 - index, s, len ) ;
+ strncpy_s( newptr+index+len, buf_len + 1 - index -len, &ptr[index], size - (index+len) ) ;
delete ptr;
ptr = newptr;
}