From 076b1310e3c74d0a0ae3076a33e40862234d19d1 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sat, 4 Nov 2023 14:24:32 +0000 Subject: [PATCH] Fix warning and errors reported by gcc --- src/cpath.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cpath.c b/src/cpath.c index 998523f..50531f6 100644 --- a/src/cpath.c +++ b/src/cpath.c @@ -7,7 +7,7 @@ #if defined(__unix__) || defined(__APPLE__) || defined(__ANDROID__) INTERNAL char path_sep = '/'; #elif defined(_WIN32) || defined(_WIN64) -INTERNAL char path_sep = '\'; +INTERNAL char path_sep = '\\'; #endif void join_root_and_leaf(const char *root, const char *leaf, char *dst); @@ -70,7 +70,9 @@ void join_root_and_leaf(const char *root, const char *leaf, char *dst) { ++leaf_start; } - strncpy(dst, root, ++root_end); + memcpy(dst, root, ++root_end); + dst[root_end] = path_sep; - strncpy(&(dst[++root_end]), &(leaf[leaf_start]), leaf_length - leaf_start); + + memcpy(&(dst[++root_end]), &(leaf[leaf_start]), leaf_length - leaf_start); }