trunk: fix some fd-leaks
authorocto <octo>
Sat, 10 Jun 2006 13:57:55 +0000 (13:57 +0000)
committerocto <octo>
Sat, 10 Jun 2006 13:57:55 +0000 (13:57 +0000)
Thanks to Olaf Rempel for this patch.

src/cpufreq.c
src/hddtemp.c
src/load.c

index b26c35e..ba0149a 100644 (file)
@@ -123,6 +123,7 @@ static void cpufreq_read (void)
                if (fgets (buffer, 16, fp) == NULL)
                {
                        syslog (LOG_WARNING, "cpufreq: fgets: %s", strerror (errno));
+                       fclose (fp);
                        return;
                }
 
index 08bbbc0..80b3419 100644 (file)
@@ -185,6 +185,7 @@ static int hddtemp_query_daemon (char *buffer, int buffer_size)
 
                        syslog (LOG_ERR, "hddtemp: Error reading from socket: %s",
                                                strerror (errno));
+                       close (fd);
                        return (-1);
                }
                buffer_fill += status;
@@ -373,6 +374,7 @@ static void hddtemp_init (void)
                                first_hddname = entry;
                        }
                }
+               fclose (fh);
        }
        else
                DBG ("Could not open /proc/partitions: %s",
index 4d43dd4..019f952 100644 (file)
@@ -107,6 +107,7 @@ static void load_read (void)
        if (fgets (buffer, 16, loadavg) == NULL)
        {
                syslog (LOG_WARNING, "load: fgets: %s", strerror (errno));
+               fclose (loadavg);
                return;
        }