diff --git a/frontend/menu/disp/rgui.c b/frontend/menu/disp/rgui.c index bd089d74bc..c35640f736 100644 --- a/frontend/menu/disp/rgui.c +++ b/frontend/menu/disp/rgui.c @@ -344,13 +344,11 @@ static void rgui_render(void) for (i = begin; i < end; i++, y += FONT_HEIGHT_STRIDE) { - char message[256], type_str[256]; - const char *path = NULL; - const char *entry_label = NULL; - unsigned type = 0; - unsigned w = 0; - char entry_title_buf[256]; - char type_str_buf[64]; + char message[PATH_MAX], type_str[PATH_MAX], + entry_title_buf[PATH_MAX], type_str_buf[PATH_MAX], + path_buf[PATH_MAX]; + const char *path = NULL, *entry_label = NULL; + unsigned type = 0, w = 0; bool selected = false; file_list_get_at_offset(driver.menu->selection_buf, i, &path, @@ -362,12 +360,13 @@ static void rgui_render(void) disp_set_label(&w, type, i, label, type_str, sizeof(type_str), - entry_label, path); + entry_label, path, + path_buf, sizeof(path_buf)); selected = (i == driver.menu->selection_ptr); menu_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2), - g_extern.frame_count / RGUI_TERM_START_X, path, selected); + g_extern.frame_count / RGUI_TERM_START_X, path_buf, selected); menu_ticker_line(type_str_buf, w, g_extern.frame_count / RGUI_TERM_START_X, type_str, selected); diff --git a/frontend/menu/disp/rmenu.c b/frontend/menu/disp/rmenu.c index fa1416e4e3..5ca730f830 100644 --- a/frontend/menu/disp/rmenu.c +++ b/frontend/menu/disp/rmenu.c @@ -217,17 +217,15 @@ static void rmenu_render(void) for (i = begin; i < end; i++, j++) { - const char *path = NULL; - const char *entry_label = NULL; - unsigned type = 0; + char message[PATH_MAX], type_str[PATH_MAX], + entry_title_buf[PATH_MAX], type_str_buf[PATH_MAX], + path_buf[PATH_MAX]; + const char *path = NULL, *entry_label = NULL; + unsigned type = 0, w = 0; + bool selected = false; + file_list_get_at_offset(menu->selection_buf, i, &path, &entry_label, &type); - char message[256]; - char type_str[256]; - unsigned w = 0; - char entry_title_buf[256]; - char type_str_buf[64]; - bool selected = false; disp_set_label(&w, type, i, label, type_str, sizeof(type_str), diff --git a/frontend/menu/disp/rmenu_xui.cpp b/frontend/menu/disp/rmenu_xui.cpp index ae71e97be1..8a44784af6 100644 --- a/frontend/menu/disp/rmenu_xui.cpp +++ b/frontend/menu/disp/rmenu_xui.cpp @@ -429,21 +429,20 @@ static void rmenu_xui_render(void) for (i = begin; i < end; i++/*, y += FONT_HEIGHT_STRIDE */) { - const char *path = NULL; - const char *entry_label = NULL; - unsigned type = 0; - file_list_get_at_offset(driver.menu->selection_buf, i, - &path, &entry_label, &type); - char message[256]; - char type_str[256]; - char entry_title_buf[256]; - char type_str_buf[64]; + char message[PATH_MAX], type_str[PATH_MAX], + entry_title_buf[PATH_MAX], type_str_buf[PATH_MAX], + path_buf[PATH_MAX]; + const char *path = NULL, *entry_label = NULL; + unsigned type = 0, w = 0; bool selected = false; - unsigned w = 0; + + file_list_get_at_offset(driver.menu->selection_buf, i, &path, + &entry_label, &type); disp_set_label(&w, type, i, label, type_str, sizeof(type_str), - entry_label, path); + entry_label, path, + path_buf, sizeof(path_buf)); selected = (i == driver.menu->selection_ptr); diff --git a/frontend/menu/disp/shared.h b/frontend/menu/disp/shared.h index 1f85de1026..cff6835a79 100644 --- a/frontend/menu/disp/shared.h +++ b/frontend/menu/disp/shared.h @@ -128,7 +128,8 @@ static void disp_set_label(unsigned *w, unsigned type, unsigned i, const char *label, char *type_str, size_t type_str_size, const char *entry_label, - const char *path) + const char *path, + char *path_buf, size_t path_buf_size) { *w = 19; @@ -206,6 +207,8 @@ static void disp_set_label(unsigned *w, unsigned type, unsigned i, driver.menu_ctx->backend->setting_set_label) driver.menu_ctx->backend->setting_set_label(type_str, type_str_size, w, type, label, entry_label, i); + + strlcpy(path_buf, path, path_buf_size); } #endif