From 5d0ea0d04b694ab1e5e83009bcb8a493e1f9a341 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Thu, 12 Sep 2019 22:51:14 +0100 Subject: Don't try to fclose() the replay log file if fopen() returned NULL. --- replay.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/replay.c b/replay.c index 654e170..7100116 100644 --- a/replay.c +++ b/replay.c @@ -190,9 +190,8 @@ int replaylines(int seconds, char *basedir) { fp = fopen(filename, "r"); if (fp == NULL) { - printf("error: could not open replay log '%s'.\n", filename); + debugprint(DEBUG_FULL, "error: could not open replay log '%s'.\n", filename); // Assume the file just doesn't exist yet - TODO - Interpret error codes to see what happened. - fclose(fp); return 0; } @@ -241,7 +240,6 @@ int readreplayline(int seconds, int linenum, char *str, struct settings *setting if (fp == NULL) { debugprint(DEBUG_CRIT, "error: readreplayline(): could not open replay log '%s'.\n", filename); - fclose(fp); return 0; } @@ -305,9 +303,8 @@ int lastspokesecondsago(char *nick, char *basedir) { fp = fopen(filename, "r"); if (fp == NULL) { - printf("error: replaylineslastspoke(): could not open replay log '%s'.\n", filename); + debugprint(DEBUG_FULL, "error: replaylineslastspoke(): could not open replay log '%s'.\n", filename); // Assume the file just doesn't exist yet - TODO - Interpret error codes to see what happened. - fclose(fp); return 0; } @@ -400,7 +397,6 @@ int writereplayline(char *str, char *basedir) { if (fp == NULL) { debugprint(DEBUG_CRIT, "error: could not open replay log '%s' for writing.\n", filename); - fclose(fp); return 0; } -- cgit v1.2.3