memory leak in Nagios 2.x utils.c

eponymous alias eponymousalias at yahoo.com
Mon Nov 26 02:18:30 CET 2007


The following code in Nagios 2.10 utils.c contains a memory leak:

   4885                
if(service_result_buffer.items==check_result_buffer_slots){
   4886  
   4887                     /* record overflow */
   4888                     service_result_buffer.overflow++;
   4889  
   4890                     /* update tail pointer */
   4891                    
service_result_buffer.tail=(service_result_buffer.tail + 1) %
check_result_buffer_slots;
   4892                 }

One needs the following lines between the overflow increment and the
tail increment:

/* We're about to discard the oldest result, to make room for the newest.
Make sure we don't create a memory leak in doing so. */
free (((service_message
**)service_result_buffer.buffer)[service_result_buffer.tail]);

Even if this code path is thought never to execute, the fix should still
be put in to guide developers who may need to modify the code base.



      ____________________________________________________________________________________
Be a better pen pal. 
Text or chat with friends inside Yahoo! Mail. See how.  http://overview.mail.yahoo.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/




More information about the Developers mailing list