} RECDB_OUT;
#ifdef HAVE_MMAP
-static int mmap_error=0;
+static int mmap_error;
#endif
#define EOL '\n'
if (fstat(fileno(recdb.f), &statinfo)) {
log_module(MAIN_LOG, LOG_ERROR, "Unable to fstat database file '%s': %s", filename, strerror(errno));
+ fclose(recdb.f);
return NULL;
}
recdb.length = (size_t)statinfo.st_size;
+ if (recdb.length == 0) {
+ return alloc_database();
+ }
#ifdef HAVE_MMAP
/* Try mmap */