From ae9d65b8a3f4a35bc01c8225f226e6420dfebe48 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 30 Nov 2014 09:33:52 +0100 Subject: mds-kbdc: add support for empty files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/raw-data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mds-kbdc/raw-data.c') diff --git a/src/mds-kbdc/raw-data.c b/src/mds-kbdc/raw-data.c index a1f8ec3..b0985fe 100644 --- a/src/mds-kbdc/raw-data.c +++ b/src/mds-kbdc/raw-data.c @@ -115,7 +115,8 @@ static char* read_file(const char* restrict pathname, size_t* restrict size) } /* Shrink the buffer so it is not excessively large. */ - fail_if (xxrealloc(old, content, buf_ptr, char)); + if (buf_ptr) /* Simplest way to handle empty files: let the have the initial allocation size. */ + fail_if (xxrealloc(old, content, buf_ptr, char)); /* Close file decriptor for the file. */ close(fd); -- cgit v1.2.3-70-g09d2