mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-28 12:53:30 +02:00
Cast via guintptr when adding/removing bitsflags on pointers
Round-tripping pointers via gsize is not guaranteed to work (the C standard only requires this for (u)inptr_t) and in fact breaks on CHERI-enabled systems such as Arm Morello where pointers are 128-bits but size_t is 64. This means the current casts would strip the high bits of the pointer and return a non-dereferenceable value. Fix this by casting the operand that holds the pointer to guintptr instead of gsize. Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
This commit is contained in:
@@ -257,7 +257,7 @@ g_param_spec_unref (GParamSpec *pspec)
|
||||
void
|
||||
g_param_spec_sink (GParamSpec *pspec)
|
||||
{
|
||||
gsize oldvalue;
|
||||
guintptr oldvalue;
|
||||
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
|
||||
|
||||
oldvalue = g_atomic_pointer_and (&pspec->qdata, ~(gsize)PARAM_FLOATING_FLAG);
|
||||
@@ -277,7 +277,7 @@ g_param_spec_sink (GParamSpec *pspec)
|
||||
GParamSpec*
|
||||
g_param_spec_ref_sink (GParamSpec *pspec)
|
||||
{
|
||||
gsize oldvalue;
|
||||
guintptr oldvalue;
|
||||
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
|
||||
|
||||
oldvalue = g_atomic_pointer_and (&pspec->qdata, ~(gsize)PARAM_FLOATING_FLAG);
|
||||
|
Reference in New Issue
Block a user