[glib/wip/pwithnall/1940-atomic-types: 2/3] gatomic: Check argument width in g_atomic_pointer_compare_and_exchange()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/pwithnall/1940-atomic-types: 2/3] gatomic: Check argument width in g_atomic_pointer_compare_and_exchange()
- Date: Wed, 20 Nov 2019 12:14:08 +0000 (UTC)
commit 75cd86f00e36484fd923d9e3bde7daa34514fa30
Author: Philip Withnall <withnall endlessm com>
Date: Wed Nov 20 12:08:46 2019 +0000
gatomic: Check argument width in g_atomic_pointer_compare_and_exchange()
Check that the new value is actually pointer-width, rather than (for
example) `sizeof (int)` which could happen if someone used `0` rather
than `NULL`.
Changes suggested by Simon McVittie.
Signed-off-by: Philip Withnall <withnall endlessm com>
Helps: #1940
glib/gatomic.h | 1 +
1 file changed, 1 insertion(+)
---
diff --git a/glib/gatomic.h b/glib/gatomic.h
index 646a30df4..fb78c0cc1 100644
--- a/glib/gatomic.h
+++ b/glib/gatomic.h
@@ -187,6 +187,7 @@ G_END_DECLS
#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \
(G_GNUC_EXTENSION ({ \
+ G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \
__typeof__ ((oldval)) gapcae_oldval = (oldval); \
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
(void) (0 ? (gpointer) *(atomic) : NULL); \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]