From 91758d2e510ee051eb4ebc2f0245aecc7bed6504 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 5 Nov 2015 09:00:52 +0100 Subject: [PATCH] CID 22439 Unchecked return value from library --- src/reports.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/reports.c b/src/reports.c index 45ed7e75f..f30175bab 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1657,12 +1657,18 @@ int reports(void) time_t ltime = time(NULL); int retval = 0; char path[MAX_PATH]; + const char * rpath = reportpath(); log_info("Writing reports for turn %d:", turn); report_donations(); remove_empty_units(); - _mkdir(reportpath()); + if (_access(rpath, 0) < 0) { + if (_mkdir(rpath) != 0) { + log_error("could not create reports directory %s: %s", rpath, strerror(errno)); + abort(); + } + } sprintf(path, "%s/reports.txt", reportpath()); mailit = fopen(path, "w"); if (mailit == NULL) {