From 722d9b98af83eb9be7e826133ac6570c3baf87a5 Mon Sep 17 00:00:00 2001 From: hippydave Date: Tue, 9 Jul 2019 16:37:23 +0100 Subject: [PATCH] More fixes --- common/menu-entry.c | 3 +-- common/menu-list.c | 5 ++++- common/menu.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/menu-entry.c b/common/menu-entry.c index 2bfec48..250c3da 100644 --- a/common/menu-entry.c +++ b/common/menu-entry.c @@ -494,8 +494,7 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) { strptr = getSlash(me->path); if (strptr[0] == '/') strptr++; int strptrLen = strlen(strptr); - snprintf(tempbuf, sizeof(tempbuf)-1, "%.*s.%.*s.star", (int)(strlen(me->path) - strptrLen), me->path, (int)strptrLen, strptr); - strcpy(me->starpath, tempbuf); + snprintf(me->starpath, sizeof(me->starpath)-1, "%.*s.%.*s.star", (int)(strlen(me->path) - strptrLen), me->path, (int)strptrLen, strptr); me->starred = fileExists(me->starpath); return true; diff --git a/common/menu-list.c b/common/menu-list.c index 2244578..61227bc 100644 --- a/common/menu-list.c +++ b/common/menu-list.c @@ -101,7 +101,10 @@ static void menuSort(void) { menuEntry_s** list = (menuEntry_s**)calloc(nEntries, sizeof(menuEntry_s*)); if(list == NULL) return; menuEntry_s** listStar = (menuEntry_s**)calloc(nEntries, sizeof(menuEntry_s*)); - if(listStar == NULL) return; + if(listStar == NULL) { + free(list); + return; + } menuEntry_s* p = m->firstEntry; for(i = 0; i < nEntries; ++i) { diff --git a/common/menu.c b/common/menu.c index 6ed8c29..19357f5 100644 --- a/common/menu.c +++ b/common/menu.c @@ -38,7 +38,7 @@ void toggleStarState(menuEntry_s* arg) { } else { if (!fileExists(me->starpath)) { FILE* f = fopen(me->starpath, "w"); - fclose(f); + if (f) fclose(f); } } me->starred = fileExists(me->starpath);