summaryrefslogtreecommitdiff
blob: 0bd3a85b018cb25b9ed4d18f747db40e219ebf58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From 8a028c250a82b667562efcfdf51d35506383adbb Mon Sep 17 00:00:00 2001
From: Mart Raudsepp <leio@gentoo.org>
Date: Wed, 19 Dec 2018 16:22:21 +0200
Subject: [PATCH] tests: Allocate gvariant data from the heap to guarantee
 alignment

On glib-2-58 branch we don't have !455, thus we need aligned data
for the gvariant tests to not fail on i686.

Fixes #1626
---
 glib/tests/gvariant.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c
index 8047ef5e8..5ca7b964e 100644
--- a/glib/tests/gvariant.c
+++ b/glib/tests/gvariant.c
@@ -4770,6 +4770,7 @@ test_stack_dict_init (void)
 static void
 test_normal_checking_tuples (void)
 {
+  gpointer aligned_data;
   const guint8 data[] = {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
     'a', '(', 'a', 'o', 'a', 'o', 'a', 'a', 'o', 'a', 'a', 'o', ')'
@@ -4778,13 +4779,15 @@ test_normal_checking_tuples (void)
   GVariant *variant = NULL;
   GVariant *normal_variant = NULL;
 
-  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size,
+  aligned_data = g_memdup (data, size); /* guarantee alignment */
+  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size,
                                      FALSE, NULL, NULL);
   g_assert_nonnull (variant);
 
   normal_variant = g_variant_get_normal_form (variant);
   g_assert_nonnull (normal_variant);
 
+  g_free (aligned_data);
   g_variant_unref (normal_variant);
   g_variant_unref (variant);
 }
@@ -4896,6 +4899,7 @@ test_recursion_limits_array_in_variant (void)
 static void
 test_normal_checking_array_offsets (void)
 {
+  gpointer aligned_data;
   const guint8 data[] = {
     0x07, 0xe5, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'g',
@@ -4904,13 +4908,15 @@ test_normal_checking_array_offsets (void)
   GVariant *variant = NULL;
   GVariant *normal_variant = NULL;
 
-  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size,
+  aligned_data = g_memdup (data, size); /* guarantee alignment */
+  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size,
                                      FALSE, NULL, NULL);
   g_assert_nonnull (variant);
 
   normal_variant = g_variant_get_normal_form (variant);
   g_assert_nonnull (normal_variant);
 
+  g_free (aligned_data);
   g_variant_unref (normal_variant);
   g_variant_unref (variant);
 }
@@ -4944,6 +4950,7 @@ test_normal_checking_tuple_offsets (void)
 static void
 test_normal_checking_empty_object_path (void)
 {
+  gpointer aligned_data;
   const guint8 data[] = {
     0x20, 0x20, 0x00, 0x00, 0x00, 0x00,
     '(', 'h', '(', 'a', 'i', 'a', 'b', 'i', 'o', ')', ')',
@@ -4952,13 +4959,15 @@ test_normal_checking_empty_object_path (void)
   GVariant *variant = NULL;
   GVariant *normal_variant = NULL;
 
-  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size,
+  aligned_data = g_memdup (data, size); /* guarantee alignment */
+  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size,
                                      FALSE, NULL, NULL);
   g_assert_nonnull (variant);
 
   normal_variant = g_variant_get_normal_form (variant);
   g_assert_nonnull (normal_variant);
 
+  g_free (aligned_data);
   g_variant_unref (normal_variant);
   g_variant_unref (variant);
 }
-- 
2.17.0