mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-10 04:45:48 +01:00
Fix a possible use-after-free.
If g_mapped_file_new fails, then `version` will be freed, but it was already added to the hash table. This means there could be a use-after-free while doing a lookup on the hash table the next time.
This commit is contained in:
parent
d17edde568
commit
6747ec55dd
@ -1405,7 +1405,6 @@ enumerate_namespace_versions (const gchar *namespace,
|
|||||||
g_free (version);
|
g_free (version);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
g_hash_table_insert (found_versions, version, version);
|
|
||||||
|
|
||||||
path = g_build_filename (dirname, entry, NULL);
|
path = g_build_filename (dirname, entry, NULL);
|
||||||
mfile = g_mapped_file_new (path, FALSE, &error);
|
mfile = g_mapped_file_new (path, FALSE, &error);
|
||||||
@ -1422,6 +1421,7 @@ enumerate_namespace_versions (const gchar *namespace,
|
|||||||
candidate->path = path;
|
candidate->path = path;
|
||||||
candidate->version = version;
|
candidate->version = version;
|
||||||
candidates = g_slist_prepend (candidates, candidate);
|
candidates = g_slist_prepend (candidates, candidate);
|
||||||
|
g_hash_table_add (found_versions, version);
|
||||||
}
|
}
|
||||||
g_dir_close (dir);
|
g_dir_close (dir);
|
||||||
index++;
|
index++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user