diff --git a/libs/string/string.h b/libs/string/string.h index bbd5ca36..09965e13 100644 --- a/libs/string/string.h +++ b/libs/string/string.h @@ -213,8 +213,8 @@ inline char* string_clone( const char* other, Allocator& allocator ){ /// The returned buffer must be released with \c string_release using a matching \p allocator. template inline char* string_clone_range( StringRange range, Allocator& allocator ){ - char* copied = strncpy( string_new( range.size(), allocator ), range.data(), range.size() ); - copied[range.size()] = '\0'; + char* copied = string_new( range.size(), allocator ); + *std::copy_n( range.data(), range.size(), copied ) = '\0'; return copied; }