[libgnome-keyring] Double check operation references
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnome-keyring] Double check operation references
- Date: Tue, 31 Jan 2012 12:50:19 +0000 (UTC)
commit 767a3a755c10081694c19b62bbcd76d440e27673
Author: Stef Walter <stefw gnome org>
Date: Tue Jan 31 13:47:47 2012 +0100
Double check operation references
* Print a warning if an invalid operation is referenced
library/gkr-operation.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/library/gkr-operation.c b/library/gkr-operation.c
index fc3ecc9..9e04cc1 100644
--- a/library/gkr-operation.c
+++ b/library/gkr-operation.c
@@ -96,8 +96,21 @@ gkr_operation_init (void)
GkrOperation*
gkr_operation_ref (GkrOperation *op)
{
+ gint old;
+
g_assert (op);
- g_atomic_int_inc (&op->refs);
+
+#if GLIB_CHECK_VERSION (2,30,0)
+ old = g_atomic_int_add (&op->refs, 1);
+#else
+ old = g_atomic_int_exchange_and_add (&op->refs, 1);
+#endif
+
+ if (old <= 0) {
+ g_warning ("invalid or unreferenced gnome-keyring operation in use");
+ return NULL;
+ }
+
return op;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]