NSCA memleak fix

Mark Ferlatte ferlatte at cryptio.net
Sat Oct 25 00:43:17 CEST 2003


Fix for a fairly nasty memory leak in the nsca daemon.  Without this patch,
nsca was growing to ~80MB overnight under my (~1000 passive check) loads.

Unfortunately, there is still another leak in there somewhere, but it's much
much smaller now.

From my testing, the leak is definately related to mcrypt; with mcrypt
disabled, there is no leak that I can see.

Patch against CVS from today is attached.

M
-------------- next part --------------
Index: utils.c
===================================================================
RCS file: /cvsroot/nagios/nsca/src/utils.c,v
retrieving revision 1.4
diff -u -r1.4 utils.c
--- utils.c	15 Oct 2003 23:17:46 -0000	1.4
+++ utils.c	24 Oct 2003 22:37:28 -0000
@@ -254,6 +254,14 @@
         /* mcrypt cleanup */
         if(encryption_method!=ENCRYPT_NONE && encryption_method!=ENCRYPT_XOR)
                 mcrypt_generic_end(CI->td);
+				free(CI->key);
+				CI->key = NULL;
+				free(CI->IV);
+				CI->IV = NULL;
+				free(CI->mcrypt_algorithm);
+				CI->mcrypt_algorithm = NULL;
+				free(CI->mcrypt_mode);
+				CI->mcrypt_mode = NULL;
 #endif
 
         free(CI);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20031024/be12d195/attachment.sig>


More information about the Developers mailing list