Fix heap-use-after-free when resource loaded with load_threaded_request is never fetched

Co-authored-by: Pedro J. Estébanez <pedrojrulez@gmail.com>
This commit is contained in:
Haoyu Qiu 2023-10-22 22:59:46 +08:00
parent 8c25a98fdf
commit dc7e309f48
1 changed files with 3 additions and 2 deletions

View File

@ -1053,8 +1053,9 @@ void ResourceLoader::clear_thread_load_tasks() {
thread_load_mutex.lock();
}
for (KeyValue<String, LoadToken *> &E : user_load_tokens) {
memdelete(E.value);
while (user_load_tokens.begin()) {
// User load tokens remove themselves from the map on destruction.
memdelete(user_load_tokens.begin()->value);
}
user_load_tokens.clear();