ganglia / monitor-core

Ganglia Monitoring core
BSD 3-Clause "New" or "Revised" License
491 stars 246 forks source link

g25_config.c: resource leak ? #245

Closed dcb314 closed 8 years ago

dcb314 commented 8 years ago

$ egrep "fopen|fclose" ../BUILD/ganglia-3.7.2/gmond/g25_config.c fp = fopen( path, "r"); $

Suggest add call to missing fclose.

hawson commented 8 years ago

While you're technically correct, look at how the code is actually called.

Line 350 (https://github.com/hawson/monitor-core/blob/master/gmond/g25_config.c#L350) is part of the print_ganglia_25_config() function, which returns 0 after successfully converting an old version 2.5 configuration file, or 1 if there was an error.

The funcition is called once, from gmond.c: 3305: exit (print_ganglia_25_config( args_info.convert_arg ));

So yes, there's a leak, right before the program exits.

That said, I'm not even sure that fp is actually used for anything in that function...