mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 06:32:48 +00:00
Merge pull request #11306 from jdgleaver/mem-leak-fix
Fix string_list memory leaks
This commit is contained in:
commit
87708ef123
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user