From c8e91e571cc2450da917ffc284deb5dc4ddf773c Mon Sep 17 00:00:00 2001 From: Victor Chernyakin Date: Thu, 4 Apr 2024 10:13:08 -0700 Subject: [PATCH] Fix `strncpy()` call to use nuklear API (#595) --- example/file_browser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/example/file_browser.c b/example/file_browser.c index 6bf23c2..30f2a46 100644 --- a/example/file_browser.c +++ b/example/file_browser.c @@ -345,7 +345,8 @@ media_init(struct media *media) static void file_browser_reload_directory_content(struct file_browser *browser, const char *path) { - strncpy(browser->directory, path, MAX_PATH_LEN); + const size_t path_len = nk_strlen(path) + 1; + NK_MEMCPY(browser->directory, path, MIN(path_len, MAX_PATH_LEN)); browser->directory[MAX_PATH_LEN - 1] = 0; dir_free_list(browser->files, browser->file_count); dir_free_list(browser->directories, browser->dir_count);