From 67a758d3b76b01913139db65f4ce059a25f3500a Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Mon, 9 Apr 2018 02:59:55 +0000
Subject: [PATCH] Bug-fix: The GCES macro already prints and *frees* the error
 string, so you can't print and free it again after calling that macro.

---
 src/sbbs3/ftpsrvr.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/sbbs3/ftpsrvr.c b/src/sbbs3/ftpsrvr.c
index f53fd9710d..2f5fac87cd 100644
--- a/src/sbbs3/ftpsrvr.c
+++ b/src/sbbs3/ftpsrvr.c
@@ -296,12 +296,13 @@ static int ftp_close_socket(SOCKET* sock, CRYPT_SESSION *sess, int line)
 	return(result);
 }
 
-#define GCES(status, sock, session, estr, action) do {                      \
+#define GCES(status, sock, session, estr, action) do {                  \
 	int GCES_level;                                                     \
 	get_crypt_error_string(status, session, &estr, action, &GCES_level);\
-	if (estr) {                                                         \
+	if (estr != NULL) {                                                 \
 		lprintf(GCES_level, "%04d TLS %s", sock, estr);                 \
-		free_crypt_attrstr(estr);                                   \
+		free_crypt_attrstr(estr);										\
+		estr=NULL;														\
 	}                                                                   \
 } while (0)
 
@@ -1954,10 +1955,6 @@ static BOOL start_tls(SOCKET *sock, CRYPT_SESSION *sess, BOOL resp)
 	}
 	if ((status = cryptCreateSession(sess, CRYPT_UNUSED, CRYPT_SESSION_SSL_SERVER)) != CRYPT_OK) {
 		GCES(status, *sock, CRYPT_UNUSED, estr, "creating session");
-		if (estr) {
-			lprintf(level, "%04d TLS %s", *sock, estr);
-			free_crypt_attrstr(estr);
-		}
 		if (resp)
 			sockprintf(*sock, *sess, "431 TLS not available");
 		return FALSE;
-- 
GitLab