File pacemaker-crm_resource-memleak.patch of Package pacemaker.14737

commit 8aaba73310e8f7ac48b7f89869627c0230fe58c8
Author: Jan Pokorný <jpokorny@redhat.com>
Date:   Thu Oct 1 18:15:34 2015 +0200

    Medium: crm_resource: fix a memleak
    
    $ ./BasicSanity.sh -v cli
    > [..]
    >  * Passed: cibadmin       - Create a resource
    >  =#=#=#= Begin test: Create a resource meta attribute =#=#=#=
    >  Set 'dummy' option: id=dummy-meta_attributes-is-managed set=dummy-meta_attributes name=is-managed=false
    > +==00:00:00:01.966 1247== 11 bytes in 1 blocks are definitely lost in loss record 2 of 10
    > +==00:00:00:01.966 1247==    at 0x4A08987: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    > +==00:00:00:01.966 1247==    by 0x403AA4: main (crm_resource.c:522)
    > +==00:00:00:01.966 1247==
    > [..]
    
    Signed-off-by: Jan Pokorný <jpokorny@redhat.com>

diff --git a/tools/crm_resource.c b/tools/crm_resource.c
index 80e99df19..8bc70962d 100644
--- a/tools/crm_resource.c
+++ b/tools/crm_resource.c
@@ -614,7 +614,7 @@ main(int argc, char **argv)
     rc = cib_conn->cmds->signon(cib_conn, crm_system_name, cib_command);
     if (rc != pcmk_ok) {
         CMD_ERR("Error signing on to the CIB service: %s", pcmk_strerror(rc));
-        return crm_exit(rc);
+        goto bail;
     }
 
     /* Populate working set from XML file if specified or CIB query otherwise */
@@ -1015,7 +1015,8 @@ main(int argc, char **argv)
             if (node && is_remote_node(node)) {
                 if (node->details->remote_rsc == NULL || node->details->remote_rsc->running_on == NULL) {
                     CMD_ERR("No lrmd connection detected to remote node %s", host_uname);
-                    return -ENXIO;
+                    rc = -ENXIO;
+                    goto bail;
                 }
                 node = node->details->remote_rsc->running_on->data;
                 router_node = node->details->uname;
@@ -1087,6 +1088,8 @@ main(int argc, char **argv)
 
   bail:
 
+    free(our_pid);
+
     if (data_set.input != NULL) {
         cleanup_alloc_calculations(&data_set);
     }
openSUSE Build Service is sponsored by