I was surprised that I found there is /*resource leak*/  in the comment

It turns out that Beam complains about it and I thought BEAM made a mistake there.
"
1657 : gshi 1.32 /* BEAM think this is a memory leak, but actually it is handle nicely 1658 : * in cl_msg_replace: old value is freed and new value is saved
1659 :                 */
"

Actually it was my mistake.

-Guochun


[email protected] wrote:
linux-ha CVS committal

Author  : lars
Host : Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/clplumbing


Modified Files:
cl_msg_types.c

Log Message:
Bug #1162 (fix by gshi): cl_msg_replace() duplicate the value and assign
it to the field, frees the old value, i.e. in compress2uncompress, the
msg from wirefmt2msg() in line 1650, cl_msg_types.c is lost, therefore
memory leaks.


===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/clplumbing/cl_msg_types.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- cl_msg_types.c      17 May 2006 23:22:33 -0000      1.37
+++ cl_msg_types.c      10 Jul 2006 19:09:57 -0000      1.38
@@ -1639,6 +1639,7 @@
        char            buf[MAXMSG];
        size_t          buflen = MAXMSG;        
        struct ha_msg*  msgfield;
+       int err;
        
        if (cl_decompress_field(msg, index, buf, &buflen) != HA_OK){
                cl_log(LOG_ERR, "%s: compress field failed",
@@ -1656,7 +1657,11 @@
        /* BEAM think this is a memory leak, but actually it is handle nicely
         * in cl_msg_replace: old value is freed and new value is saved
         */
-       return cl_msg_replace(msg, index, (char*)msgfield, 0, FT_UNCOMPRESS);/* 
resource leak */                
+       err = cl_msg_replace(msg, index, (char*)msgfield, 0, FT_UNCOMPRESS);/* 
resource leak */
+
+       ha_msg_del(msgfield);
+       
+       return err;
 }
/*


_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs

_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to