diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-05-09 14:06:57 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-05-09 14:06:57 (GMT) |
commit | fa4de0b3ae03ad440a311148b18509c6ee7470b6 (patch) | |
tree | bb31ca8e3433aa86b9435b1c8b932f908b760d50 /src/glibext | |
parent | 421c9d8b228f4926fabe06a19fda86d9023f1e96 (diff) |
Fixed a memory leak when deleting work groups.
Diffstat (limited to 'src/glibext')
-rw-r--r-- | src/glibext/delayed.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/glibext/delayed.c b/src/glibext/delayed.c index 9bac68a..e93edc2 100644 --- a/src/glibext/delayed.c +++ b/src/glibext/delayed.c @@ -498,7 +498,7 @@ static void g_work_group_finalize(GWorkGroup *group) /****************************************************************************** * * -* Paramètres : type = type dont seront marqués tous les travaux donnés. * +* Paramètres : id = identifiant accordé au nouveau groupe. * * * * Description : Crée un nouveau thread dédié à un type de travaux donné. * * * @@ -1021,6 +1021,7 @@ wgroup_id_t g_work_queue_define_work_group(GWorkQueue *queue) void g_work_queue_delete_work_group(GWorkQueue *queue, wgroup_id_t id) { size_t i; /* Boucle de parcours */ + GWorkGroup *group; /* Groupe de travail manipulé */ #ifndef NDEBUG bool found; /* Repérage du groupe visé */ #endif @@ -1032,8 +1033,13 @@ void g_work_queue_delete_work_group(GWorkQueue *queue, wgroup_id_t id) g_mutex_lock(&queue->mutex); for (i = 0; i < queue->groups_count; i++) - if (g_work_group_get_id(queue->groups[i]) == id) + { + group = queue->groups[i]; + + if (g_work_group_get_id(group) == id) { + g_object_unref(G_OBJECT(group)); + memmove(&queue->groups[i], &queue->groups[i + 1], (queue->groups_count - i - 1) * sizeof(GWorkGroup *)); @@ -1049,6 +1055,8 @@ void g_work_queue_delete_work_group(GWorkQueue *queue, wgroup_id_t id) } + } + assert(found); g_cond_broadcast(&queue->wait_all); |