1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2025-07-17 15:37:52 +02:00

registrybackend: fix possible mem leak

If the parameters do not validate we would leak the memory.
This commit is contained in:
Ignacio Casal Quinteiro
2016-01-26 11:42:05 +01:00
parent 305a9b12c9
commit 8f7aa273de

@@ -388,17 +388,19 @@ typedef struct
} RegistryCacheItem; } RegistryCacheItem;
static GNode * static GNode *
registry_cache_add_item (GNode *parent, registry_cache_add_item (GNode *parent,
gchar *name, gchar *name,
RegistryValue value, RegistryValue value,
gint ref_count) gint ref_count)
{ {
RegistryCacheItem *item = g_slice_new (RegistryCacheItem); RegistryCacheItem *item;
GNode *cache_node; GNode *cache_node;
g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (parent != NULL, NULL); g_return_val_if_fail (parent != NULL, NULL);
item = g_slice_new (RegistryCacheItem);
/* Ref count should be the number of watch points above this node */ /* Ref count should be the number of watch points above this node */
item->ref_count = ref_count; item->ref_count = ref_count;
@@ -413,6 +415,7 @@ registry_cache_add_item (GNode *parent,
cache_node = g_node_new (item); cache_node = g_node_new (item);
g_node_append (parent, cache_node); g_node_append (parent, cache_node);
return cache_node; return cache_node;
} }