Cib memleak

The recent version of cib shows the large number of memory leaks every time a resource is migrated.
One of them seems have been existing since 1.0 and needs to be backported.

Here is a snippet from the valgrind output. Tested revision is: 512f868 2012-06-05 

---- 
==19047== 
==19047== HEAP SUMMARY:
==19047==     in use at exit: 4,780,962 bytes in 18,063 blocks
==19047==   total heap usage: 105,724 allocs, 87,661 frees, 28,348,512 bytes allocated
==19047== 
==19047== 2 bytes in 1 blocks are possibly lost in loss record 60 of 1,940
==19047==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19047==    by 0x355CE7FDF1: strdup (in /lib64/libc-2.12.so)
==19047==    by 0x36F0A11C59: qb_log_filter_ctl2 (log.c:489)
==19047==    by 0x50597EC: set_crm_log_level (utils.c:890)
==19047==    by 0x40661F: write_cib_contents (io.c:613)
==19047==    by 0x506FDB2: crm_trigger_dispatch (mainloop.c:91)
==19047==    by 0x355CA38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x40ED9E: cib_init (main.c:527)
==19047==    by 0x40F384: main (main.c:224)
==19047== 
==19047== 27 bytes in 1 blocks are possibly lost in loss record 350 of 1,940
==19047==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==19047==    by 0x5056ABB: crm_strdup_fn (utils.c:1179)
==19047==    by 0x505A281: crm_log_init (utils.c:772)
==19047==    by 0x40F0D0: main (main.c:142)
==19047== 
==19047== 32 bytes in 1 blocks are possibly lost in loss record 388 of 1,940
==19047==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==19047==    by 0x36F0A11FA0: qb_log_callsites_register (log.c:356)
==19047==    by 0x36F0A13A81: _log_register_callsites (log_dcs.c:62)
==19047==    by 0x36F0A122A8: qb_log_init (log.c:740)
==19047==    by 0x5059E21: crm_log_init (utils.c:795)
==19047==    by 0x40F0D0: main (main.c:142)
==19047== 
==19047== 32 bytes in 1 blocks are possibly lost in loss record 389 of 1,940
==19047==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==19047==    by 0x36F0A11FA0: qb_log_callsites_register (log.c:356)
==19047==    by 0x36F0A122BB: qb_log_init (log.c:742)
==19047==    by 0x5059E21: crm_log_init (utils.c:795)
==19047==    by 0x40F0D0: main (main.c:142)
==19047== 
==19047== 40 bytes in 1 blocks are possibly lost in loss record 476 of 1,940
==19047==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==19047==    by 0x36F0A11C11: qb_log_filter_ctl2 (log.c:482)
==19047==    by 0x50597EC: set_crm_log_level (utils.c:890)
==19047==    by 0x40661F: write_cib_contents (io.c:613)
==19047==    by 0x506FDB2: crm_trigger_dispatch (mainloop.c:91)
==19047==    by 0x355CA38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x40ED9E: cib_init (main.c:527)
==19047==    by 0x40F384: main (main.c:224)
==19047== 
==19047== 192 bytes in 6 blocks are possibly lost in loss record 1,083 of 1,940
==19047==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==19047==    by 0x36F0A11FA0: qb_log_callsites_register (log.c:356)
==19047==    by 0x36F0A12AEA: _log_so_walk_callback (log.c:693)
==19047==    by 0x355CF23C85: dl_iterate_phdr (in /lib64/libc-2.12.so)
==19047==    by 0x36F0A122C9: qb_log_init (log.c:743)
==19047==    by 0x5059E21: crm_log_init (utils.c:795)
==19047==    by 0x40F0D0: main (main.c:142)
==19047== 
==19047== 7,401 (96 direct, 7,305 indirect) bytes in 1 blocks are definitely lost in loss record 1,884 of 1,940
==19047==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19047==    by 0x3568A5227B: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A54861: xmlSetProp (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x505C1E1: crm_xml_add (xml.c:350)
==19047==    by 0x40DDBD: cib_common_callback (callbacks.c:284)
==19047==    by 0x36F0A0E693: _process_request_.clone.0 (ipcs.c:589)
==19047==    by 0x36F0A0E9D5: qb_ipcs_dispatch_connection_request (ipcs.c:689)
==19047==    by 0x5070409: gio_read_socket (mainloop.c:339)
==19047==    by 0x355CA38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x40ED9E: cib_init (main.c:527)
==19047==    by 0x40F384: main (main.c:224)
==19047== 
==19047== 12,232 (96 direct, 12,136 indirect) bytes in 1 blocks are definitely lost in loss record 1,911 of 1,940
==19047==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19047==    by 0x3568A5227B: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A54861: xmlSetProp (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x505C1E1: crm_xml_add (xml.c:350)
==19047==    by 0x40BA10: send_peer_reply (callbacks.c:517)
==19047==    by 0x40C097: cib_process_request (callbacks.c:696)
==19047==    by 0x40DBE5: cib_common_callback_worker (callbacks.c:233)
==19047==    by 0x40DDE8: cib_common_callback (callbacks.c:292)
==19047==    by 0x36F0A0E693: _process_request_.clone.0 (ipcs.c:589)
==19047==    by 0x36F0A0E9D5: qb_ipcs_dispatch_connection_request (ipcs.c:689)
==19047==    by 0x5070409: gio_read_socket (mainloop.c:339)
==19047==    by 0x355CA38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x40ED9E: cib_init (main.c:527)
==19047==    by 0x40F384: main (main.c:224)
==19047== 
==19047== 15,860 (120 direct, 15,740 indirect) bytes in 1 blocks are definitely lost in loss record 1,917 of 1,940
==19047==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19047==    by 0x3568AF3F4D: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568AF4EBA: xmlSAX2StartElementNs (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A454F9: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4611B: xmlParseElement (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D131: xmlParseDocument (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D424: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x505DAD3: string2xml (xml.c:533)
==19047==    by 0x40DD27: cib_common_callback (callbacks.c:240)
==19047==    by 0x36F0A0E693: _process_request_.clone.0 (ipcs.c:589)
==19047==    by 0x36F0A0E9D5: qb_ipcs_dispatch_connection_request (ipcs.c:689)
==19047==    by 0x5070409: gio_read_socket (mainloop.c:339)
==19047==    by 0x355CA38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x40ED9E: cib_init (main.c:527)
==19047==    by 0x40F384: main (main.c:224)
==19047== 
==19047== 18,213 (120 direct, 18,093 indirect) bytes in 1 blocks are definitely lost in loss record 1,920 of 1,940
==19047==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19047==    by 0x3568AF3F4D: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568AF4EBA: xmlSAX2StartElementNs (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A454F9: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4611B: xmlParseElement (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A46649: xmlParseContent (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A461A0: xmlParseElement (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A46649: xmlParseContent (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A461A0: xmlParseElement (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A46649: xmlParseContent (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A461A0: xmlParseElement (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A46649: xmlParseContent (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A461A0: xmlParseElement (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A46649: xmlParseContent (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A461A0: xmlParseElement (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D131: xmlParseDocument (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D424: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x505DDD1: filename2xml (xml.c:707)
==19047==    by 0x40522B: retrieveCib (io.c:258)
==19047==    by 0x40619A: write_cib_contents (io.c:708)
==19047==    by 0x506FDB2: crm_trigger_dispatch (mainloop.c:91)
==19047==    by 0x355CA38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x40ED9E: cib_init (main.c:527)
==19047== 
==19047== 36,189 (600 direct, 35,589 indirect) bytes in 5 blocks are definitely lost in loss record 1,929 of 1,940
==19047==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19047==    by 0x3568A525ED: xmlNewNodeEatName (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A55E5B: xmlNewDocNodeEatName (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568AF5119: xmlSAX2StartElementNs (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A454F9: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4611B: xmlParseElement (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D131: xmlParseDocument (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D424: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x505DAD3: string2xml (xml.c:533)
==19047==    by 0x40DD27: cib_common_callback (callbacks.c:240)
==19047==    by 0x36F0A0E693: _process_request_.clone.0 (ipcs.c:589)
==19047==    by 0x36F0A0E9D5: qb_ipcs_dispatch_connection_request (ipcs.c:689)
==19047==    by 0x5070409: gio_read_socket (mainloop.c:339)
==19047==    by 0x355CA38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x40ED9E: cib_init (main.c:527)
==19047==    by 0x40F384: main (main.c:224)
==19047== 
==19047== 77,624 (480 direct, 77,144 indirect) bytes in 5 blocks are definitely lost in loss record 1,935 of 1,940
==19047==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19047==    by 0x3568A5227B: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568AF4EFF: xmlSAX2StartElementNs (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A454F9: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4611B: xmlParseElement (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D131: xmlParseDocument (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D424: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x505DAD3: string2xml (xml.c:533)
==19047==    by 0x40DD27: cib_common_callback (callbacks.c:240)
==19047==    by 0x36F0A0E693: _process_request_.clone.0 (ipcs.c:589)
==19047==    by 0x36F0A0E9D5: qb_ipcs_dispatch_connection_request (ipcs.c:689)
==19047==    by 0x5070409: gio_read_socket (mainloop.c:339)
==19047==    by 0x355CA38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x40ED9E: cib_init (main.c:527)
==19047==    by 0x40F384: main (main.c:224)
==19047== 
==19047== 796,770 (14,256 direct, 782,514 indirect) bytes in 81 blocks are definitely lost in loss record 1,938 of 1,940
==19047==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19047==    by 0x3568A52854: xmlNewDoc (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568AF6518: xmlSAX2StartDocument (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D265: xmlParseDocument (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x3568A4D424: ??? (in /usr/lib64/libxml2.so.2.7.6)
==19047==    by 0x505DAD3: string2xml (xml.c:533)
==19047==    by 0x40DD27: cib_common_callback (callbacks.c:240)
==19047==    by 0x36F0A0E693: _process_request_.clone.0 (ipcs.c:589)
==19047==    by 0x36F0A0E9D5: qb_ipcs_dispatch_connection_request (ipcs.c:689)
==19047==    by 0x5070409: gio_read_socket (mainloop.c:339)
==19047==    by 0x355CA38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x355CA3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==19047==    by 0x40ED9E: cib_init (main.c:527)
==19047==    by 0x40F384: main (main.c:224)
==19047== 
==19047== LEAK SUMMARY:
==19047==    definitely lost: 15,768 bytes in 95 blocks
==19047==    indirectly lost: 948,521 bytes in 6,056 blocks
==19047==      possibly lost: 325 bytes in 11 blocks
==19047==    still reachable: 3,816,348 bytes in 11,901 blocks
==19047==         suppressed: 0 bytes in 0 blocks
==19047== Reachable blocks (those to which a pointer was found) are not shown.
==19047== To see them, rerun with: --leak-check=full --show-reachable=yes
==19047== 
==19047== For counts of detected and suppressed errors, rerun with: -v
==19047== Use --track-origins=yes to see where uninitialised values come from
==19047== ERROR SUMMARY: 124 errors from 15 contexts (suppressed: 6 from 6)