sftp_close_handle: free any trailing write chunks
This commit is contained in:
parent
727043074a
commit
95db6cc62c
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;
|
||||
unsigned char *s, *data = NULL;
|
||||
int rc;
|
||||
struct sftp_write_chunk *chunk;
|
||||
|
||||
if (handle->close_state == libssh2_NB_state_idle) {
|
||||
_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);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
LIBSSH2_FREE(session, handle);
|
||||
|
Loading…
x
Reference in New Issue
Block a user