File bsc#1211678-0004-Fix-tools-Free-command-line-related-memory.patch of Package pacemaker.32052

From a393b57c540d223192fa937ee69115d1fcdc3674 Mon Sep 17 00:00:00 2001
From: Chris Lumens <clumens@redhat.com>
Date: Tue, 26 Jan 2021 09:54:37 -0500
Subject: [PATCH 4/6] Fix: tools: Free command-line related memory.

Also, the "goto done" in crm_simulate can go away because pcmk__cli_help
does not return.
---
 tools/crm_diff.c     | 2 ++
 tools/crm_error.c    | 9 +++++++++
 tools/crm_node.c     | 2 ++
 tools/crm_rule.c     | 2 ++
 tools/crm_simulate.c | 3 ++-
 5 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/tools/crm_diff.c b/tools/crm_diff.c
index 9467a26c9..950622490 100644
--- a/tools/crm_diff.c
+++ b/tools/crm_diff.c
@@ -327,6 +327,8 @@ main(int argc, char **argv)
     }
 
     if (args->version) {
+        g_strfreev(processed_args);
+        pcmk__free_arg_context(context);
         /* FIXME:  When crm_diff is converted to use formatted output, this can go. */
         pcmk__cli_help('v', CRM_EX_USAGE);
     }
diff --git a/tools/crm_error.c b/tools/crm_error.c
index c3d647e3b..29bf327ee 100644
--- a/tools/crm_error.c
+++ b/tools/crm_error.c
@@ -85,6 +85,8 @@ main(int argc, char **argv)
 
     if (!g_option_context_parse_strv(context, &processed_args, &error)) {
         fprintf(stderr, "%s: %s\n", g_get_prgname(), error->message);
+        g_strfreev(processed_args);
+        pcmk__free_arg_context(context);
         return CRM_EX_USAGE;
     }
 
@@ -93,6 +95,8 @@ main(int argc, char **argv)
     }
 
     if (args->version) {
+        g_strfreev(processed_args);
+        pcmk__free_arg_context(context);
         /* FIXME:  When crm_error is converted to use formatted output, this can go. */
         pcmk__cli_help('v', CRM_EX_USAGE);
     }
@@ -131,6 +135,8 @@ main(int argc, char **argv)
             char *help = g_option_context_get_help(context, TRUE, NULL);
             fprintf(stderr, "%s", help);
             g_free(help);
+            g_strfreev(processed_args);
+            pcmk__free_arg_context(context);
             return CRM_EX_USAGE;
         }
 
@@ -145,5 +151,8 @@ main(int argc, char **argv)
             }
         }
     }
+
+    g_strfreev(processed_args);
+    pcmk__free_arg_context(context);
     return CRM_EX_OK;
 }
diff --git a/tools/crm_node.c b/tools/crm_node.c
index cac41a9fa..9172f974f 100644
--- a/tools/crm_node.c
+++ b/tools/crm_node.c
@@ -554,6 +554,8 @@ main(int argc, char **argv)
     }
 
     if (args->version) {
+        g_strfreev(processed_args);
+        pcmk__free_arg_context(context);
         /* FIXME:  When crm_node is converted to use formatted output, this can go. */
         pcmk__cli_help('v', CRM_EX_USAGE);
     }
diff --git a/tools/crm_rule.c b/tools/crm_rule.c
index 2871f3d6d..44abca104 100644
--- a/tools/crm_rule.c
+++ b/tools/crm_rule.c
@@ -258,6 +258,8 @@ main(int argc, char **argv)
     }
 
     if (args->version) {
+        g_strfreev(processed_args);
+        pcmk__free_arg_context(context);
         /* FIXME:  When crm_rule is converted to use formatted output, this can go. */
         pcmk__cli_help('v', CRM_EX_USAGE);
     }
diff --git a/tools/crm_simulate.c b/tools/crm_simulate.c
index 9efd37a15..3da7471ea 100644
--- a/tools/crm_simulate.c
+++ b/tools/crm_simulate.c
@@ -923,9 +923,10 @@ main(int argc, char **argv)
     }
 
     if (args->version) {
+        g_strfreev(processed_args);
+        pcmk__free_arg_context(context);
         /* FIXME:  When crm_simulate is converted to use formatted output, this can go. */
         pcmk__cli_help('v', CRM_EX_USAGE);
-        goto done;
     }
 
     if (optind > argc) {
-- 
2.35.3

openSUSE Build Service is sponsored by