GUACAMOLE-1181: Free wStream after send is complete/cancelled.

This commit is contained in:
Michael Jumper 2020-10-28 20:23:37 -07:00
parent 558eb149f4
commit 2c86e20ab9
2 changed files with 12 additions and 8 deletions

View File

@ -89,10 +89,9 @@ void guac_rdp_common_svc_write(guac_rdp_common_svc* svc,
return; return;
} }
/* NOTE: Data sent via pVirtualChannelWriteEx MUST always be dynamically /* NOTE: The wStream sent via pVirtualChannelWriteEx will automatically be
* allocated, as it will be automatically freed using free(). If provided, * freed later with a call to Stream_Free() when handling the
* the last parameter (user data) MUST be a pointer to a wStream, as it * corresponding write cancel/completion event. */
* will automatically be freed by FreeRDP using Stream_Free() */
svc->_entry_points.pVirtualChannelWriteEx(svc->_init_handle, svc->_entry_points.pVirtualChannelWriteEx(svc->_init_handle,
svc->_open_handle, Stream_Buffer(output_stream), svc->_open_handle, Stream_Buffer(output_stream),
Stream_GetPosition(output_stream), output_stream); Stream_GetPosition(output_stream), output_stream);

View File

@ -28,10 +28,8 @@
#include <stdlib.h> #include <stdlib.h>
/** /**
* Event handler for events which deal with data transmitted over an open SVC. * Event handler for events which deal with data transmitted over an open SVC,
* This specific implementation of the event handler currently handles only the * including receipt of inbound data and completion of outbound writes.
* CHANNEL_EVENT_DATA_RECEIVED event, delegating actual handling of that event
* to guac_rdp_common_svc_process_receive().
* *
* The FreeRDP requirements for this function follow those of the * The FreeRDP requirements for this function follow those of the
* VirtualChannelOpenEventEx callback defined within Microsoft's RDP API: * VirtualChannelOpenEventEx callback defined within Microsoft's RDP API:
@ -83,6 +81,13 @@ static VOID guac_rdp_common_svc_handle_open_event(LPVOID user_param,
DWORD open_handle, UINT event, LPVOID data, UINT32 data_length, DWORD open_handle, UINT event, LPVOID data, UINT32 data_length,
UINT32 total_length, UINT32 data_flags) { UINT32 total_length, UINT32 data_flags) {
/* Free stream data after send is complete */
if ((event == CHANNEL_EVENT_WRITE_CANCELLED
|| event == CHANNEL_EVENT_WRITE_COMPLETE) && data != NULL) {
Stream_Free((wStream*) data, TRUE);
return;
}
/* Ignore all events except for received data */ /* Ignore all events except for received data */
if (event != CHANNEL_EVENT_DATA_RECEIVED) if (event != CHANNEL_EVENT_DATA_RECEIVED)
return; return;