mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-23 01:22:37 +03:00
sftp_close_handle: free any trailing write chunks
This commit is contained in:
13
src/sftp.c
13
src/sftp.c
@@ -1757,6 +1757,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
|
|||||||
ssize_t packet_len = handle->handle_len + 13;
|
ssize_t packet_len = handle->handle_len + 13;
|
||||||
unsigned char *s, *data = NULL;
|
unsigned char *s, *data = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
struct sftp_write_chunk *chunk;
|
||||||
|
|
||||||
if (handle->close_state == libssh2_NB_state_idle) {
|
if (handle->close_state == libssh2_NB_state_idle) {
|
||||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Closing handle");
|
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Closing handle");
|
||||||
@@ -1832,6 +1833,18 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
|
|||||||
LIBSSH2_FREE(session, handle->u.dir.names_packet);
|
LIBSSH2_FREE(session, handle->u.dir.names_packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* remove pending write chunks */
|
||||||
|
do {
|
||||||
|
chunk = _libssh2_list_first(&handle->write_list);
|
||||||
|
if(chunk) {
|
||||||
|
struct sftp_write_chunk *next =
|
||||||
|
_libssh2_list_next(&chunk->node);
|
||||||
|
_libssh2_list_remove(&chunk->node);
|
||||||
|
LIBSSH2_FREE(session, chunk);
|
||||||
|
chunk = next;
|
||||||
|
}
|
||||||
|
} while(chunk);
|
||||||
|
|
||||||
handle->close_state = libssh2_NB_state_idle;
|
handle->close_state = libssh2_NB_state_idle;
|
||||||
|
|
||||||
LIBSSH2_FREE(session, handle);
|
LIBSSH2_FREE(session, handle);
|
||||||
|
|||||||
Reference in New Issue
Block a user