flose files & free memory when not needed
[debian/dhcpd-pools.git] / src / getdata.c
index fe513ae..c25d87e 100644 (file)
@@ -60,10 +60,10 @@ extern char *malloc();
 int parse_leases(void)
 {
        FILE *dhcpd_leases;
-       char *line, *ipstring, *macstring;
+       char *line, *ipstring, *macstring = NULL;
        struct in_addr inp;
        struct stat lease_file_stats;
-       struct macaddr_t *macaddr_p;
+       struct macaddr_t *macaddr_p = NULL;
        unsigned long leasesmallocsize;
        unsigned long touchesmallocsize;
        unsigned long backupsmallocsize;
@@ -163,6 +163,7 @@ int parse_leases(void)
        if (macaddr != NULL) {
                free(macstring);
        }
+       fclose(dhcpd_leases);
        return 0;
 }
 
@@ -452,5 +453,6 @@ char *parse_config(int is_include, char *config_file,
                }
        }
        free(word);
+       fclose(dhcpd_config);
        return next_free_shared_name;
 }