mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 04:15:49 +01:00
Bug 652197 – Improper handling of double values in GDBusMessage
Matthew Bucknall pointed out GDBusMessage does not serialize/deserialize double values correctly on platforms with strict alignment constraints (in my particular case, ARM926EJ-S). This was reported in https://bugzilla.gnome.org/show_bug.cgi?id=652197 Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
f819aa5f17
commit
13b93f0c48
@ -1184,14 +1184,15 @@ parse_value_from_blob (GMemoryInputStream *mis,
|
|||||||
goto fail;
|
goto fail;
|
||||||
if (!just_align)
|
if (!just_align)
|
||||||
{
|
{
|
||||||
guint64 v;
|
union {
|
||||||
gdouble *encoded;
|
guint64 v_uint64;
|
||||||
|
gdouble v_double;
|
||||||
|
} u;
|
||||||
G_STATIC_ASSERT (sizeof (gdouble) == sizeof (guint64));
|
G_STATIC_ASSERT (sizeof (gdouble) == sizeof (guint64));
|
||||||
v = g_data_input_stream_read_uint64 (dis, NULL, &local_error);
|
u.v_uint64 = g_data_input_stream_read_uint64 (dis, NULL, &local_error);
|
||||||
if (local_error != NULL)
|
if (local_error != NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
encoded = (gdouble *) &v;
|
ret = g_variant_new_double (u.v_double);
|
||||||
ret = g_variant_new_double (*encoded);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
|
else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
|
||||||
@ -1941,11 +1942,13 @@ append_value_to_blob (GVariant *value,
|
|||||||
padding_added = ensure_output_padding (mos, dos, 8);
|
padding_added = ensure_output_padding (mos, dos, 8);
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
{
|
{
|
||||||
guint64 *encoded;
|
union {
|
||||||
gdouble v = g_variant_get_double (value);
|
guint64 v_uint64;
|
||||||
|
gdouble v_double;
|
||||||
|
} u;
|
||||||
G_STATIC_ASSERT (sizeof (gdouble) == sizeof (guint64));
|
G_STATIC_ASSERT (sizeof (gdouble) == sizeof (guint64));
|
||||||
encoded = (guint64 *) &v;
|
u.v_double = g_variant_get_double (value);
|
||||||
g_data_output_stream_put_uint64 (dos, *encoded, NULL, NULL);
|
g_data_output_stream_put_uint64 (dos, u.v_uint64, NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
|
else if (g_variant_type_equal (type, G_VARIANT_TYPE_STRING))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user