mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-25 11:42:10 +01:00
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
This commit is contained in:
parent
844332ef31
commit
75cd86f00e
@ -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); \
|
||||
|
Loading…
x
Reference in New Issue
Block a user