From e7d411e01d7e8422c1ce74ee8f263387e38c5d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Sat, 17 Feb 2024 15:01:56 -0500 Subject: [PATCH] Move sftp_state inside ssh_mutex. This won't matter now since only one thread ever touches it, but when cool stuff happens, it could. --- src/syncterm/ssh.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/syncterm/ssh.c b/src/syncterm/ssh.c index 85ca873d55..3adb7c02ec 100644 --- a/src/syncterm/ssh.c +++ b/src/syncterm/ssh.c @@ -457,11 +457,13 @@ key_not_present(sftp_filehandle_t f, const char *priv) bufsz += 4096; } if (!sftpc_read(sftp_state, f, off, (bufsz - bufpos > 1024) ? 1024 : bufsz - bufpos, &r)) { + free(buf); + pthread_mutex_lock(&ssh_mutex); if (sftp_state->err_code == SSH_FX_EOF) { - free(buf); + pthread_mutex_unlock(&ssh_mutex); return true; } - free(buf); + pthread_mutex_unlock(&ssh_mutex); return false; } memcpy(&buf[bufpos], r->c_str, r->len); -- GitLab