Code

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 b26c35e161eb09d17c329ce8d22c1c498f76f3c8..ba0149ad1f390298af4049690cc56c9458f4c8b7 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 08bbbc0270bc5a0c0a4b3c712a4f7bb6cfea1382..80b3419bee76d3e96efacb242bdba4f946efc5be 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 4d43dd45cb7f9a93f391117d2048b70ced049261..019f952c07066e7c753dbd193cc40d58ccab11d6 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;
        }