mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 02:38:08 +02:00
libnm-glib: prevent possible access of freed memory
valgrind reported that 'path' is already freed by the time we get to _nm_object_cache_remove_by_path().
This commit is contained in:
parent
54ef8f3224
commit
4a370a9fa5
2 changed files with 4 additions and 12 deletions
|
|
@ -34,18 +34,12 @@ _init_cache (void)
|
|||
cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_object_cache_remove_by_path (const char *path)
|
||||
static void
|
||||
_nm_object_cache_remove_by_path (char *path)
|
||||
{
|
||||
_init_cache ();
|
||||
g_hash_table_remove (cache, path);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_object_cache_remove_by_object (NMObject *object)
|
||||
{
|
||||
_init_cache ();
|
||||
g_hash_table_remove (cache, nm_object_get_path (object));
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -57,7 +51,7 @@ _nm_object_cache_add (NMObject *object)
|
|||
path = g_strdup (nm_object_get_path (object));
|
||||
g_hash_table_insert (cache, path, object);
|
||||
g_object_set_data_full (G_OBJECT (object), "nm-object-cache-tag",
|
||||
path, (GDestroyNotify) _nm_object_cache_remove_by_path);
|
||||
g_strdup (path), (GDestroyNotify) _nm_object_cache_remove_by_path);
|
||||
}
|
||||
|
||||
NMObject *
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ G_BEGIN_DECLS
|
|||
/* Returns referenced object from the cache */
|
||||
NMObject *_nm_object_cache_get (const char *path);
|
||||
void _nm_object_cache_add (NMObject *object);
|
||||
void _nm_object_cache_remove_by_object (NMObject *object);
|
||||
void _nm_object_cache_remove_by_path (const char *path);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue