memory leak in Nagios 2.x utils.c

Ethan Galstad nagios at nagios.org
Fri Dec 14 20:57:21 CET 2007


eponymous alias wrote:
> 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.

Thanks for the note. I'll get this in CVS shortly...


Ethan Galstad
Nagios Developer
___
Email: nagios at nagios.org
Web:   www.nagios.org

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace




More information about the Developers mailing list