Fixed use after free

This commit is contained in:
Scoopta 2020-04-10 21:55:03 -07:00
parent 7308465f26
commit 6ce49cd43d

View File

@ -1360,7 +1360,11 @@ static void parse_mods(char* key, void (*action)(void)) {
mod = NULL; mod = NULL;
} }
struct key_entry* entry = malloc(sizeof(struct key_entry)); struct key_entry* entry = malloc(sizeof(struct key_entry));
entry->mod = mod; if(mod == NULL) {
entry->mod = NULL;
} else {
entry->mod = strdup(mod);
}
entry->action = action; entry->action = action;
map_put_void(keys, str, entry); map_put_void(keys, str, entry);
} while((str = strtok_r(NULL, ",", &save_ptr)) != NULL); } while((str = strtok_r(NULL, ",", &save_ptr)) != NULL);