From 256487c95aa9c303e173324caa5a074d5fe8b7b8 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 29 Oct 2020 11:59:13 -0700 Subject: [PATCH] GUACAMOLE-1181: Only free wStream after send if FreeRDP requires this. --- configure.ac | 25 ++++++++++++++++++- .../plugins/guac-common-svc/guac-common-svc.c | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1873a6fb..485be581 100644 --- a/configure.ac +++ b/configure.ac @@ -623,7 +623,7 @@ then fi -# Variation in memory internal allocation/free behavior +# Variation in memory internal allocation/free behavior for bitmaps if test "x${have_freerdp2}" = "xyes" then @@ -647,6 +647,29 @@ then fi +# Variation in memory internal allocation/free behavior for channel streams +if test "x${have_freerdp2}" = "xyes" +then + + # FreeRDP 2.0.0-rc3 through 2.0.0-rc4 automatically free the wStream + # provided to pVirtualChannelWriteEx(). This changed in commit 1b78b59, and + # implementations must manually free the wStream after it is no longer + # needed (after the write is complete or cancelled). + AC_MSG_CHECKING([whether pVirtualChannelWriteEx() frees the wStream upon completion]) + AC_EGREP_CPP([\"2\\.0\\.0-(rc|dev)[3-4]\"], [ + + #include + FREERDP_VERSION_FULL + + ], + [AC_MSG_RESULT([yes])] + [AC_DEFINE([FREERDP_SVC_CORE_FREES_WSTREAM],, + [Whether pVirtualChannelWriteEx() frees the wStream upon completion])], + [AC_MSG_RESULT([no])]) + +fi + + # Glyph callback variants if test "x${have_freerdp2}" = "xyes" then diff --git a/src/protocols/rdp/plugins/guac-common-svc/guac-common-svc.c b/src/protocols/rdp/plugins/guac-common-svc/guac-common-svc.c index d00af95b..0a464850 100644 --- a/src/protocols/rdp/plugins/guac-common-svc/guac-common-svc.c +++ b/src/protocols/rdp/plugins/guac-common-svc/guac-common-svc.c @@ -81,12 +81,14 @@ static VOID guac_rdp_common_svc_handle_open_event(LPVOID user_param, DWORD open_handle, UINT event, LPVOID data, UINT32 data_length, UINT32 total_length, UINT32 data_flags) { +#ifndef FREERDP_SVC_CORE_FREES_WSTREAM /* 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; } +#endif /* Ignore all events except for received data */ if (event != CHANNEL_EVENT_DATA_RECEIVED)