From 658e26bd49dcdb349eb66c40ff485db0e0b30737 Mon Sep 17 00:00:00 2001 From: Philippe Pepiot Date: Sat, 30 Oct 2010 23:16:44 +0200 Subject: [PATCH] parse: detect empty file + fix memleak --- src/parse/parse.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/parse/parse.c b/src/parse/parse.c index c214448..d9948b2 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -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; }