From e562dbf456e460366ff3fd37df36912d198fe3d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Sat, 2 Mar 2024 16:15:45 -0500
Subject: [PATCH] Fix memory leak in sftp_opendir()

Found by Coverity.
---
 src/sbbs3/sftp.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/sbbs3/sftp.cpp b/src/sbbs3/sftp.cpp
index 76ea7178e6..b6cb0b7bae 100644
--- a/src/sbbs3/sftp.cpp
+++ b/src/sbbs3/sftp.cpp
@@ -1589,7 +1589,9 @@ sftp_opendir(sftp_str_t path, void *cb_data)
 	if (h == nullptr) {
 		return sftps_send_error(sbbs->sftp_state, SSH_FX_FAILURE, "Handle allocation failure");
 	}
-	return sftps_send_handle(sbbs->sftp_state, h);
+	bool ret = sftps_send_handle(sbbs->sftp_state, h);
+	free_sftp_str(h);
+	return ret;
 }
 
 // TODO: This is still too ugly... should be split into multiple functions.
-- 
GitLab