summaryrefslogtreecommitdiff
path: root/replay.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2023-08-01 23:57:07 +0100
committerLuke Bratch <luke@bratch.co.uk>2023-08-01 23:57:07 +0100
commit35b494cafe1e3ff1b278040999da09b061c82fbc (patch)
tree8423d172fffe55068d0f9916f251f237a67bc07c /replay.c
parent3b2b776a1f3684429c5014b964db54737e662dda (diff)
Always close() the replay log file if it's been opened.
Diffstat (limited to 'replay.c')
-rw-r--r--replay.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/replay.c b/replay.c
index cda8fb3..de11988 100644
--- a/replay.c
+++ b/replay.c
@@ -461,6 +461,7 @@ long lastspokelinenumber(char *nick, char *basedir) {
// Try to split
if ((token = strsep(&strcopy, " ")) == NULL) {
debugprint(DEBUG_CRIT, "lastspokelinenumber(): error splitting string on iteration '%d', returning -1!\n", i);
+ fclose(fp);
return -1;
}
// Copy into the token array (strlen + 1 to get the NULL terminator)
@@ -472,12 +473,14 @@ long lastspokelinenumber(char *nick, char *basedir) {
// Make sure there were at least three tokens
if (counter < 3) {
debugprint(DEBUG_CRIT, "lastspokelinenumber(): not enough tokens on line, only '%d', returning -1!\n", counter);
+ fclose(fp);
return -1;
}
// Make sure it started with a valid timestamp
int timestamp = gettimestamp(tokens[0]);
if (timestamp < 0) {
+ fclose(fp);
debugprint(DEBUG_CRIT, "lastspokelinenumber(): line didn't start with a timestamp, returning -1!\n", counter);
}
@@ -622,6 +625,7 @@ int doreplaylastspoke(int sourcefd, long linenumber, struct client *clients, str
snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Log replay complete.", ircdstate->ircnick);
sendtoclient(sourcefd, outgoingmsg, clients, settings, 0);
+ fclose(fp);
return 1;
}