From 51cb7273a3a6d6c14e64e07ff5cff3f0daf2c579 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Windows 11)" <rob@synchro.net>
Date: Tue, 24 Dec 2024 13:32:18 -0800
Subject: [PATCH] Close file descriptor in error condition

Fix CID 516461
---
 src/sbbs3/writemsg.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/sbbs3/writemsg.cpp b/src/sbbs3/writemsg.cpp
index 6f21110da2..59513f013e 100644
--- a/src/sbbs3/writemsg.cpp
+++ b/src/sbbs3/writemsg.cpp
@@ -673,6 +673,7 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *subj, int mode,
 		}
 		length=(long)filelength(file);
 		if(length < 0) {
+			close(file);
 			errormsg(WHERE, ERR_LEN, msgtmp, length);
 			free(buf);
 			return false;
-- 
GitLab