From 283b4b7d694f276e421b0db823a4905983699255 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 7 Jun 2012 09:41:50 +0300 Subject: [PATCH] gattrib: Fix protection of GAttrib while calling callbacks The callbacks could result with the reference count dropping to 0 and the object being freed. This patch fixes the issue by adding one extra reference for the duration of the timeout function. --- attrib/gattrib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/attrib/gattrib.c b/attrib/gattrib.c index fedc42e9d..0f011f0a1 100644 --- a/attrib/gattrib.c +++ b/attrib/gattrib.c @@ -255,6 +255,8 @@ static gboolean disconnect_timeout(gpointer data) struct _GAttrib *attrib = data; struct command *c; + g_attrib_ref(attrib); + c = g_queue_pop_head(attrib->requests); if (c == NULL) goto done; @@ -273,6 +275,8 @@ static gboolean disconnect_timeout(gpointer data) done: attrib->stale = TRUE; + g_attrib_unref(attrib); + return FALSE; } -- 2.47.3