From e46db37c03b6adae1594729c2c5c86e65701d95b Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 9 Feb 2010 13:00:39 +0000 Subject: [PATCH] conform: fix stack corruption in test-behaviours.c The test was calling g_object_get to fetch the "opacity-start" property (unsigned int) into a guint8 local variable. It's a bit of a mean trap given that the getter function returns guint8 values so this also adds a comment explaining what's going on. --- tests/conform/test-behaviours.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/conform/test-behaviours.c b/tests/conform/test-behaviours.c index 669e14f..ad0ac16 100644 --- a/tests/conform/test-behaviours.c +++ b/tests/conform/test-behaviours.c @@ -19,6 +19,7 @@ opacity_behaviour (BehaviourFixture *fixture) { ClutterBehaviour *behaviour; guint8 start, end; + guint starti; behaviour = clutter_behaviour_opacity_new (fixture->alpha, 0, 255); g_assert (CLUTTER_IS_BEHAVIOUR_OPACITY (behaviour)); @@ -38,14 +39,16 @@ opacity_behaviour (BehaviourFixture *fixture) clutter_behaviour_opacity_set_bounds (CLUTTER_BEHAVIOUR_OPACITY (behaviour), 255, 0); - - start = 0; - g_object_get (G_OBJECT (behaviour), "opacity-start", &start, NULL); + /* XXX: The gobject property is actually a unsigned int not unsigned char + * property so we have to be careful not to corrupt the stack by passing + * a guint8 pointer here... */ + starti = 0; + g_object_get (G_OBJECT (behaviour), "opacity-start", &starti, NULL); if (g_test_verbose ()) g_print ("BehaviourOpacity:start = %d (expected: 255)\n", start); - g_assert_cmpint (start, ==, 255); + g_assert_cmpint (starti, ==, 255); g_object_unref (behaviour); } -- 2.7.4