File bsc#1211678-0008-Fix-tools-avoid-memory-leaks-in-crm_mon.patch of Package pacemaker.29789

From a30ff4a87f291a0c9e03c4efb9c9046d2ac594f1 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 27 Jul 2021 11:26:59 -0500
Subject: [PATCH 8/8] Fix: tools: avoid memory leaks in crm_mon

could be significant in an interactive session

regressions introduced in 2.0.4 and 2.0.5
---
 lib/pengine/bundle.c    | 3 ++-
 lib/pengine/clone.c     | 5 ++---
 lib/pengine/pe_output.c | 3 +++
 3 files changed, 7 insertions(+), 4 deletions(-)

Index: pacemaker-2.0.5+20201202.ba59be712/lib/pengine/bundle.c
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/lib/pengine/bundle.c
+++ pacemaker-2.0.5+20201202.ba59be712/lib/pengine/bundle.c
@@ -1527,7 +1527,7 @@ pe__bundle_xml(pcmk__output_t *out, va_l
     for (GList *gIter = bundle_data->replicas; gIter != NULL;
          gIter = gIter->next) {
         pe__bundle_replica_t *replica = gIter->data;
-        char *id = crm_itoa(replica->offset);
+        char *id = NULL;
         gboolean print_ip, print_child, print_ctnr, print_remote;
 
         CRM_ASSERT(replica);
@@ -1561,6 +1561,7 @@ pe__bundle_xml(pcmk__output_t *out, va_l
             CRM_ASSERT(rc == pcmk_rc_ok);
         }
 
+        id = crm_itoa(replica->offset);
         rc = pe__name_and_nvpairs_xml(out, true, "replica", 1, "id", id);
         free(id);
         CRM_ASSERT(rc == pcmk_rc_ok);
Index: pacemaker-2.0.5+20201202.ba59be712/lib/pengine/clone.c
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/lib/pengine/clone.c
+++ pacemaker-2.0.5+20201202.ba59be712/lib/pengine/clone.c
@@ -779,10 +779,10 @@ pe__clone_html(pcmk__output_t *out, va_l
         pcmk__add_word(&list_text, &list_text_len, host->details->uname);
         active_instances++;
     }
+    g_list_free(master_list);
 
     if (list_text != NULL) {
         out->list_item(out, NULL, " Masters: [ %s ]", list_text);
-        g_list_free(master_list);
         free(list_text);
         list_text = NULL;
         list_text_len = 0;
@@ -800,6 +800,7 @@ pe__clone_html(pcmk__output_t *out, va_l
         pcmk__add_word(&list_text, &list_text_len, host->details->uname);
         active_instances++;
     }
+    g_list_free(started_list);
 
     if (list_text != NULL) {
         if (pcmk_is_set(rsc->flags, pe_rsc_promotable)) {
@@ -814,8 +815,6 @@ pe__clone_html(pcmk__output_t *out, va_l
         } else {
             out->list_item(out, NULL, " Started: [ %s ]", list_text);
         }
-
-        g_list_free(started_list);
         free(list_text);
         list_text = NULL;
         list_text_len = 0;
Index: pacemaker-2.0.5+20201202.ba59be712/lib/pengine/pe_output.c
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/lib/pengine/pe_output.c
+++ pacemaker-2.0.5+20201202.ba59be712/lib/pengine/pe_output.c
@@ -1127,6 +1127,8 @@ pe__node_text(pcmk__output_t *out, va_li
 
                     out->end_list(out);
                     out->end_list(out);
+
+                    g_list_free(rscs);
                 }
 
             } else {
openSUSE Build Service is sponsored by