Page 1 of 1

[Nagios-devel] memory leak in Nagios 2.x utils.c

Posted: Sun Nov 25, 2007 5:18 pm
by Guest
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 post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]