From a7662ef315d7f369cbbc438dec76e3b9db3cd5ba Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Tue, 5 Oct 2010 02:11:22 -0400 Subject: [PATCH] GVariant tests: fix bad allignment assumption One of the GVariant test cases allocates a pair of character arrays on the stack and then passes them to functions that assume that they will be aligned to a multiple of two. This is not the case for some versions of GCC (4.0.3 on PowerPC). --- glib/tests/gvariant.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c index 74eee40..2c3c048 100644 --- a/glib/tests/gvariant.c +++ b/glib/tests/gvariant.c @@ -3489,21 +3489,24 @@ test_gv_byteswap () * * just test a few simple cases here to make sure they each work */ - guchar valid_data[] = { 'a', '\0', swapped16(66), 2, + guchar validbytes[] = { 'a', '\0', swapped16(66), 2, 0, 'b', '\0', swapped16(77), 2, 5, 11 }; - guchar corrupt_data[] = { 'a', '\0', swapped16(66), 2, + guchar corruptbytes[] = { 'a', '\0', swapped16(66), 2, 0, 'b', '\0', swapped16(77), 2, 6, 11 }; + guint valid_data[4], corrupt_data[4]; GVariant *value, *swapped; gchar *string, *string2; + memcpy (valid_data, validbytes, sizeof validbytes); + memcpy (corrupt_data, corruptbytes, sizeof corruptbytes); /* trusted */ value = g_variant_new_from_data (G_VARIANT_TYPE ("a(sn)"), - valid_data, sizeof valid_data, TRUE, + valid_data, sizeof validbytes, TRUE, NULL, NULL); swapped = g_variant_byteswap (value); g_variant_unref (value); @@ -3515,7 +3518,7 @@ test_gv_byteswap () /* untrusted but valid */ value = g_variant_new_from_data (G_VARIANT_TYPE ("a(sn)"), - valid_data, sizeof valid_data, FALSE, + valid_data, sizeof validbytes, FALSE, NULL, NULL); swapped = g_variant_byteswap (value); g_variant_unref (value); @@ -3527,7 +3530,7 @@ test_gv_byteswap () /* untrusted, invalid */ value = g_variant_new_from_data (G_VARIANT_TYPE ("a(sn)"), - corrupt_data, sizeof corrupt_data, FALSE, + corrupt_data, sizeof corruptbytes, FALSE, NULL, NULL); string = g_variant_print (value, FALSE); swapped = g_variant_byteswap (value); -- 2.7.4