From 7a5ab6153f8ae04f40d349e8185530ae3ba841b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Fri, 29 Dec 2023 20:53:14 -0500
Subject: [PATCH] Handle unlikely case where sftpc_finish() is called while
 waiting and before the first response.

---
 src/sftp/sftp_client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/sftp/sftp_client.c b/src/sftp/sftp_client.c
index 666b50f1e0..8306ee2c61 100644
--- a/src/sftp/sftp_client.c
+++ b/src/sftp/sftp_client.c
@@ -164,6 +164,8 @@ get_result(sftpc_state_t state)
 		return false;
 	if (WaitForEvent(state->recv_event, INFINITE) != WAIT_OBJECT_0)
 		return false;
+	if (state->rxp == NULL)
+		return false;
 	if (state->rxp->type != SSH_FXP_VERSION) {
 		uint32_t id = sftp_get32(state->rxp);
 		if (id != state->id) {
-- 
GitLab