Skip to content

Commit

Permalink
Fix _z_str_n_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Jul 3, 2024
1 parent 3f051e6 commit 68e4361
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/collections/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ void _z_str_free(char **src) {

void _z_str_copy(char *dst, const char *src) {
size_t size = _z_str_size(src);
strncpy(dst, src, size);
strncpy(dst, src, size - 1);
dst[size - 1] = '\0'; // No matter what, strings are always null-terminated upon copy
}

void _z_str_n_copy(char *dst, const char *src, size_t size) {
strncpy(dst, src, size);
strncpy(dst, src, size - 1);
dst[size - 1] = '\0'; // No matter what, strings are always null-terminated upon copy
}

Expand Down

0 comments on commit 68e4361

Please sign in to comment.