From de355d225cfd074eea6cfa8cd3572d41ddd7cb08 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 13 Sep 2024 01:54:08 -0400 Subject: Remove static buffer from shortcts.c as long as we put it back the way we found it u.path is a writable buffer Change-Id: I6f1e6139ce96b8edb61ad8b0ae6a6f2218eee855 --- apps/shortcuts.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'apps/shortcuts.c') diff --git a/apps/shortcuts.c b/apps/shortcuts.c index 5453422b43..adac5e3327 100644 --- a/apps/shortcuts.c +++ b/apps/shortcuts.c @@ -482,15 +482,15 @@ static int shortcut_menu_speak_item(int selected_item, void * data) { case SHORTCUT_BROWSER: { - static char path[MAX_PATH]; DIR* dir; struct dirent* entry; - char* filename = strrchr(sc->u.path, PATH_SEPCH) + 1; - if (*filename != '\0') + char* slash = strrchr(sc->u.path, PATH_SEPCH); + char* filename = slash + 1; + if (slash && *filename != '\0') { - int dirlen = (filename - sc->u.path); - strmemccpy(path, sc->u.path, dirlen + 1); - dir = opendir(path); + *slash = '\0'; /* terminate the path to open the directory */ + dir = opendir(sc->u.path); + *slash = PATH_SEPCH; /* restore fullpath */ if (dir) { while (0 != (entry = readdir(dir))) @@ -498,9 +498,12 @@ static int shortcut_menu_speak_item(int selected_item, void * data) if (!strcmp(entry->d_name, filename)) { struct dirinfo info = dir_get_info(dir, entry); + if (info.attribute & ATTR_DIRECTORY) talk_dir_or_spell(sc->u.path, NULL, false); - else talk_file_or_spell(path, filename, NULL, false); + else + talk_file_or_spell(NULL, sc->u.path, NULL, false); + closedir(dir); return 0; } -- cgit v1.2.3