From 460c44ae23a12ee435d3006736ebe2f9d4ffbdee Mon Sep 17 00:00:00 2001 From: TheFloW Date: Thu, 13 Sep 2018 15:18:19 +0200 Subject: [PATCH] Fixed memory leak --- browser.c | 9 ++++++--- file.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/browser.c b/browser.c index abfdfb1..14935b4 100644 --- a/browser.c +++ b/browser.c @@ -659,7 +659,7 @@ static void create_recent_symlink(FileListEntry *file_entry) { } static void fileBrowserHandleFile(FileListEntry *file_entry) { - snprintf(cur_file, MAX_PATH_LENGTH - 1, "%s%s", file_list.path, file_entry->name); + snprintf(cur_file, MAX_PATH_LENGTH, "%s%s", file_list.path, file_entry->name); int type = handleFile(cur_file, file_entry); // Archive mode @@ -667,7 +667,7 @@ static void fileBrowserHandleFile(FileListEntry *file_entry) { is_in_archive = 1; dir_level_archive = dir_level; - snprintf(archive_path, MAX_PATH_LENGTH - 1, "%s%s", file_list.path, file_entry->name); + snprintf(archive_path, MAX_PATH_LENGTH, "%s%s", file_list.path, file_entry->name); strcat(file_list.path, file_entry->name); addEndSlash(file_list.path); @@ -735,7 +735,7 @@ static void fileBrowserHandleSymlink(FileListEntry *file_entry) { if ((file_entry->symlink->to_file == 1 && !checkFileExist(file_entry->symlink->target_path)) || (file_entry->symlink->to_file == 0 && !checkFolderExist(file_entry->symlink->target_path))) { // TODO: What if in archive? - snprintf(cur_file, MAX_PATH_LENGTH - 1, "%s%s", file_list.path, file_entry->name); + snprintf(cur_file, MAX_PATH_LENGTH, "%s%s", file_list.path, file_entry->name); textViewer(cur_file); return; } @@ -765,6 +765,9 @@ static void fileBrowserHandleSymlink(FileListEntry *file_entry) { } fileBrowserHandleFile(resolved_file_entry); dirUp(); + + free(target_file_name); + free(target_base_directory); } int res = refreshFileList(); if (res < 0) diff --git a/file.c b/file.c index 5042253..742e6bc 100644 --- a/file.c +++ b/file.c @@ -1052,7 +1052,7 @@ int fileListGetDirectoryEntries(FileList *list, const char *path, int sort) { if (!p) { return VITASHELL_ERROR_INTERNAL; } - snprintf(p, MAX_PATH_LENGTH - 1, "%s%s%s", + snprintf(p, MAX_PATH_LENGTH, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name); Symlink* symlink = malloc(sizeof(Symlink));