parse: detect empty file + fix memleak

This commit is contained in:
Philippe Pepiot 2010-10-30 23:16:44 +02:00
parent 464f06c5c1
commit 658e26bd49

View File

@ -165,8 +165,15 @@ parse_keywords(const char *filename)
return NULL;
}
if (st.st_size == 0) {
warnx("%s: empty file", filename);
close(fd);
return NULL;
}
if (!realpath(filename, path)) {
warn("%s", filename);
close(fd);
return NULL;
}