From 1f0ae7b4ba734c965d240c88b783730eccd32038 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 22 Aug 2013 14:51:37 -0700 Subject: [PATCH] Do not use pExtendedData beyond connect handler. NULL out pExtendedData once done. --- src/protocols/rdp/guac_rdpdr/rdpdr_service.c | 6 +++++- src/protocols/rdp/guac_rdpsnd/rdpsnd_service.c | 15 ++++++++++----- src/protocols/rdp/guac_rdpsnd/rdpsnd_service.h | 5 +++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_service.c b/src/protocols/rdp/guac_rdpdr/rdpdr_service.c index 9093a2e8..3ebfb703 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_service.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_service.c @@ -93,10 +93,14 @@ void guac_rdpdr_process_connect(rdpSvcPlugin* plugin) { /* Get RDPDR plugin */ guac_rdpdrPlugin* rdpdr = (guac_rdpdrPlugin*) plugin; - /* Get client from plugin */ + /* Get client from plugin parameters */ guac_client* client = (guac_client*) plugin->channel_entry_points.pExtendedData; + /* NULL out pExtendedData so we don't lose our guac_client due to an + * automatic free() within libfreerdp */ + plugin->channel_entry_points.pExtendedData = NULL; + /* Get data from client */ rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data; diff --git a/src/protocols/rdp/guac_rdpsnd/rdpsnd_service.c b/src/protocols/rdp/guac_rdpsnd/rdpsnd_service.c index 14571a0e..3d4b8084 100644 --- a/src/protocols/rdp/guac_rdpsnd/rdpsnd_service.c +++ b/src/protocols/rdp/guac_rdpsnd/rdpsnd_service.c @@ -88,9 +88,15 @@ int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) { void guac_rdpsnd_process_connect(rdpSvcPlugin* plugin) { - /* Get audio stream from plugin */ - audio_stream* audio = (audio_stream*) - plugin->channel_entry_points.pExtendedData; + guac_rdpsndPlugin* rdpsnd = (guac_rdpsndPlugin*) plugin; + + /* Get audio stream from plugin parameters */ + audio_stream* audio = rdpsnd->audio = + (audio_stream*) plugin->channel_entry_points.pExtendedData; + + /* NULL out pExtendedData so we don't lose our audio_stream due to an + * automatic free() within libfreerdp */ + plugin->channel_entry_points.pExtendedData = NULL; #ifdef RDPSVCPLUGIN_INTERVAL_MS /* Update every 10 ms */ @@ -117,8 +123,7 @@ void guac_rdpsnd_process_receive(rdpSvcPlugin* plugin, guac_rdpsnd_pdu_header header; /* Get audio stream from plugin */ - audio_stream* audio = (audio_stream*) - plugin->channel_entry_points.pExtendedData; + audio_stream* audio = rdpsnd->audio; /* Read RDPSND PDU header */ Stream_Read_UINT8(input_stream, header.message_type); diff --git a/src/protocols/rdp/guac_rdpsnd/rdpsnd_service.h b/src/protocols/rdp/guac_rdpsnd/rdpsnd_service.h index 9c3ff56f..263e8eaf 100644 --- a/src/protocols/rdp/guac_rdpsnd/rdpsnd_service.h +++ b/src/protocols/rdp/guac_rdpsnd/rdpsnd_service.h @@ -84,6 +84,11 @@ typedef struct guac_rdpsndPlugin { */ rdpSvcPlugin plugin; + /** + * The current audio stream. + */ + audio_stream* audio; + /** * The block number of the last SNDC_WAVE (WaveInfo) PDU received. */