Merge pull request #11306 from jdgleaver/mem-leak-fix

Fix string_list memory leaks
This commit is contained in:
Autechre 2020-09-09 06:25:03 +02:00 committed by GitHub
commit 87708ef123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -438,12 +438,18 @@ end:
return ret;
}
/* Warning: 'list' must zero initialised before
* calling this function, otherwise memory leaks/
* undefined behaviour will occur */
bool file_archive_get_file_list_noalloc(struct string_list *list,
const char *path,
const char *valid_exts)
{
struct archive_extract_userdata userdata;
if (!list || !string_list_initialize(list))
return false;
strlcpy(userdata.archive_path, path, sizeof(userdata.archive_path));
userdata.current_file_path[0] = '\0';
userdata.first_extracted_file_path = NULL;
@ -457,8 +463,6 @@ bool file_archive_get_file_list_noalloc(struct string_list *list,
userdata.transfer = NULL;
userdata.dec = NULL;
if (!userdata.list)
return false;
if (!file_archive_walk(path, valid_exts,
file_archive_get_file_list_cb, &userdata))
return false;

View File

@ -164,6 +164,9 @@ bool file_archive_extract_file(char *archive_path, size_t archive_path_size,
const char *valid_exts, const char *extraction_dir,
char *out_path, size_t len);
/* Warning: 'list' must zero initialised before
* calling this function, otherwise memory leaks/
* undefined behaviour will occur */
bool file_archive_get_file_list_noalloc(struct string_list *list,
const char *path,
const char *valid_exts);

View File

@ -181,9 +181,6 @@ static void filebrowser_parse(
? path_is_compressed_file(path) : false;
rarch_system_info_t *system = runloop_get_system_info();
if (!string_list_initialize(&str_list))
return;
/* Core fully loaded, use the subsystem data */
if (system->subsystem.data)
subsystem = system->subsystem.data + content_get_subsystem();
@ -419,7 +416,7 @@ static void filebrowser_parse(
}
}
string_list_deinitialize(&str_list);
dir_list_deinitialize(&str_list);
if (items_found == 0)
{
@ -3148,7 +3145,6 @@ static unsigned menu_displaylist_parse_playlists(
#endif
}
string_list_initialize(&str_list);
if (!dir_list_initialize(&str_list, path, NULL, true,
show_hidden_files, true, false))
return count;
@ -3209,7 +3205,7 @@ static unsigned menu_displaylist_parse_playlists(
count++;
}
string_list_deinitialize(&str_list);
dir_list_deinitialize(&str_list);
return count;
}