[glib: 2/3] tests: Fix two small leaks in the actions test




commit 4eafbaba9464ccfcade26a53449db0caeccd2615
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Nov 16 14:03:36 2021 +0000

    tests: Fix two small leaks in the actions test
    
    These are known leaks, as they were being done in tests which were
    checking precondition failures.
    
    However, since we know what happens when the failures occur, we can
    still free the input data reliably, so do that.
    
    This improves the valgrind output for `actions` to show zero definite
    leaks.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 gio/tests/actions.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gio/tests/actions.c b/gio/tests/actions.c
index d48c8543a..12538e341 100644
--- a/gio/tests/actions.c
+++ b/gio/tests/actions.c
@@ -275,10 +275,12 @@ test_stateful (void)
 
   if (g_test_undefined ())
     {
+      GVariant *new_state = g_variant_ref_sink (g_variant_new_int32 (123));
       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
                              "*assertion*g_variant_is_of_type*failed*");
-      g_simple_action_set_state (action, g_variant_new_int32 (123));
+      g_simple_action_set_state (action, new_state);
       g_test_assert_expected_messages ();
+      g_variant_unref (new_state);
     }
 
   g_simple_action_set_state (action, g_variant_new_string ("hello"));
@@ -292,10 +294,12 @@ test_stateful (void)
 
   if (g_test_undefined ())
     {
+      GVariant *new_state = g_variant_ref_sink (g_variant_new_int32 (123));
       g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
                              "*assertion*!= NULL*failed*");
-      g_simple_action_set_state (action, g_variant_new_int32 (123));
+      g_simple_action_set_state (action, new_state);
       g_test_assert_expected_messages ();
+      g_variant_unref (new_state);
     }
 
   g_object_unref (action);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]