Skip to content

Commit

Permalink
Merge pull request libretro#11541 from jdgleaver/database-fix
Browse files Browse the repository at this point in the history
Fix database scans
  • Loading branch information
inactive123 authored Nov 9, 2020
2 parents 8401e89 + 54ce950 commit 8c62952
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tasks/task_database.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,10 +712,11 @@ static int database_info_list_iterate_found_match(
* running out of stack space on systems with a limited stack size.
* We should use less fullsize paths in the future so that we don't
* need to have all these big char arrays here */
char* db_crc = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char* db_playlist_base_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char* db_playlist_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char* entry_path_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
size_t str_len = PATH_MAX_LENGTH * sizeof(char);
char* db_crc = (char*)malloc(str_len);
char* db_playlist_base_str = (char*)malloc(str_len);
char* db_playlist_path = (char*)malloc(str_len);
char* entry_path_str = (char*)malloc(str_len);
char *hash = NULL;
playlist_t *playlist = NULL;
const char *db_path =
Expand All @@ -731,25 +732,25 @@ static int database_info_list_iterate_found_match(
entry_path_str[0] = '\0';

fill_short_pathname_representation_noext(db_playlist_base_str,
db_path, sizeof(db_playlist_base_str));
db_path, str_len);

strlcat(db_playlist_base_str, ".lpl", sizeof(db_playlist_base_str));
strlcat(db_playlist_base_str, ".lpl", str_len);

if (!string_is_empty(_db->playlist_directory))
fill_pathname_join(db_playlist_path, _db->playlist_directory,
db_playlist_base_str, sizeof(db_playlist_path));
db_playlist_base_str, str_len);

playlist_config_set_path(&_db->playlist_config, db_playlist_path);
playlist = playlist_init(&_db->playlist_config);

snprintf(db_crc, sizeof(db_crc), "%08X|crc", db_info_entry->crc32);
snprintf(db_crc, str_len, "%08X|crc", db_info_entry->crc32);

if (entry_path)
strlcpy(entry_path_str, entry_path, sizeof(entry_path_str));
strlcpy(entry_path_str, entry_path, str_len);

if (!string_is_empty(archive_name))
fill_pathname_join_delim(entry_path_str,
entry_path_str, archive_name, '#', sizeof(entry_path_str));
entry_path_str, archive_name, '#', str_len);

if (core_info_database_match_archive_member(
db_state->list->elems[db_state->list_index].data) &&
Expand Down

0 comments on commit 8c62952

Please sign in to comment.