diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c index 8f3df66e..69499b39 100644 --- a/src/client/menu/menu.c +++ b/src/client/menu/menu.c @@ -5695,10 +5695,18 @@ HasSkinsInDir(const char *dirname, int *num) for (j = 0; j < num_png; j ++) { - if (list_png[j] && !strchr(list_png[j] + dirname_size, '/')) + if (list_png[j]) { - *curr = list_png[j]; - curr++; + if (!strchr(list_png[j] + dirname_size, '/')) + { + *curr = list_png[j]; + curr++; + } + else + { + /* unused in final response */ + free(list_png[j]); + } } } @@ -5711,10 +5719,18 @@ HasSkinsInDir(const char *dirname, int *num) for (j = 0; j < num_pcx; j ++) { - if (list_pcx[j] && !strchr(list_pcx[j] + dirname_size, '/')) + if (list_pcx[j]) { - *curr = list_pcx[j]; - curr++; + if (!strchr(list_pcx[j] + dirname_size, '/')) + { + *curr = list_pcx[j]; + curr++; + } + else + { + /* unused in final response */ + free(list_pcx[j]); + } } } diff --git a/src/common/filesystem.c b/src/common/filesystem.c index 30490140..6e15cdbc 100644 --- a/src/common/filesystem.c +++ b/src/common/filesystem.c @@ -731,6 +731,12 @@ FS_LoadFile(const char *path, void **buffer) if (size <= 0) { + if (size == 0) + { + /* empty file, close before exit*/ + FS_FCloseFile(f); + } + if (buffer) { *buffer = NULL;