From: Benjamin Otte Date: Fri, 26 Mar 2010 19:37:09 +0000 (+0100) Subject: Fix race in g_cancellable_cancel() X-Git-Tag: 2.25.0~84 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7763678b56e3be073cc55d707a6e92fc2055ee0;p=platform%2Fupstream%2Fglib.git Fix race in g_cancellable_cancel() We need to check priv->cancelled after taking the lock. Previously we only checked it just before taking the lock, which left a small chance for a race. --- diff --git a/gio/gcancellable.c b/gio/gcancellable.c index 2d600c9..32d01ae 100644 --- a/gio/gcancellable.c +++ b/gio/gcancellable.c @@ -622,6 +622,11 @@ g_cancellable_cancel (GCancellable *cancellable) priv = cancellable->priv; G_LOCK(cancellable); + if (priv->cancelled) + { + G_UNLOCK (cancellable); + return; + } priv->cancelled = TRUE; priv->cancelled_running = TRUE;