From 2feca8994d40b59e35978e3a5fd8ce44a0f0c9d3 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 21 Mar 2022 14:01:19 +0000 Subject: [PATCH] Revert "(config_file) Prevent hash map corruption when calling config_unset()" This reverts commit e5df8f7850f49fd659e6ba8a2139f2a1f444f341. --- libretro-common/file/config_file.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 5953b0f7e7..0b90b7a7a8 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -1242,6 +1242,8 @@ void config_unset(config_file_t *conf, const char *key) if (!entry) return; + (void)RHMAP_DEL_STR(conf->entries_map, entry->key); + if (entry->key) free(entry->key); @@ -1251,16 +1253,6 @@ void config_unset(config_file_t *conf, const char *key) entry->key = NULL; entry->value = NULL; conf->modified = true; - - /* TODO/FIXME: We want to call RHMAP_DEL_STR() - * here to remove the current entry from the - * internal hash map - but RHMAP_DEL_STR() does - * not work correctly and causes hash map corruption. - * We therefore work around this by leaving the - * entry in the hash map, but setting its value - * to NULL... */ - entry = NULL; - RHMAP_SET_STR(conf->entries_map, key, entry); } void config_set_path(config_file_t *conf, const char *entry, const char *val) @@ -1468,7 +1460,7 @@ void config_file_dump(config_file_t *conf, FILE *file, bool sort) bool config_entry_exists(config_file_t *conf, const char *entry) { - return !!RHMAP_GET_STR(conf->entries_map, entry); + return (bool)RHMAP_HAS_STR(conf->entries_map, entry); } bool config_get_entry_list_head(config_file_t *conf,