From 3383bb4feb0c8c0f61b435c96f7f1538f58cb8dd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 16 Apr 2019 15:55:05 +0200 Subject: [PATCH] cli: fix crash in split_required_fields_for_con_show() Depending on the architecture (calling convention), function arguments are evaluated in one order or the other. https://bugzilla.redhat.com/show_bug.cgi?id=1700409 Fixes: 34e60bf2282e ('cli: cleanup split_required_fields_for_con_show()') (cherry picked from commit f4afb38bd90f2d96d5f8f4e60d50d7d65d24cbbe) --- clients/cli/connections.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index d3193ccb3..6ee3b49f9 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -1534,6 +1534,7 @@ split_required_fields_for_con_show (const char *input, nm_auto_free_gstring GString *str2 = NULL; gboolean group_profile = FALSE; gboolean group_active = FALSE; + gboolean do_free; if (!input) { *profile_flds = NULL; @@ -1627,8 +1628,11 @@ split_required_fields_for_con_show (const char *input, g_string_truncate (str1, str1->len - 1); if (str2->len > 0) g_string_truncate (str2, str2->len - 1); - *profile_flds = g_string_free (g_steal_pointer (&str1), str1->len == 0); - *active_flds = g_string_free (g_steal_pointer (&str2), str2->len == 0); + + do_free = (str1->len == 0); + *profile_flds = g_string_free (g_steal_pointer (&str1), do_free); + do_free = (str2->len == 0); + *active_flds = g_string_free (g_steal_pointer (&str2), do_free); return TRUE; }