Fix Memory Leaks in RdpSnd
authorDavid PHAM-VAN <d.phamvan@inuvika.com>
Tue, 28 Jun 2016 21:39:29 +0000 (14:39 -0700)
committerDavid PHAM-VAN <d.phamvan@inuvika.com>
Mon, 19 Sep 2016 18:27:25 +0000 (11:27 -0700)
channels/rdpsnd/client/mac/rdpsnd_mac.c
channels/rdpsnd/client/rdpsnd_main.c [changed mode: 0644->0755]
channels/rdpsnd/client/winmm/rdpsnd_winmm.c

index 3c7f13c..a73f8ac 100644 (file)
@@ -327,6 +327,8 @@ static void rdpsnd_mac_waveplay(rdpsndDevicePlugin* device, RDPSND_WAVE* wave)
        length = wave->length > audioBuffer->mAudioDataBytesCapacity ? audioBuffer->mAudioDataBytesCapacity : wave->length;
     
        CopyMemory(audioBuffer->mAudioData, wave->data, length);
+       free(wave->data);
+       wave->data = NULL;
        audioBuffer->mAudioDataByteSize = length;
        audioBuffer->mUserData = wave;
        
old mode 100644 (file)
new mode 100755 (executable)
index 2133339..baf0c64
@@ -7,6 +7,7 @@
  * Copyright 2012-2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
  * Copyright 2015 Thincast Technologies GmbH
  * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ * Copyright 2016 David PHAM-VAN <d.phamvan@inuvika.com>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1476,6 +1477,9 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle, UINT
                        break;
 
                case CHANNEL_EVENT_TERMINATED:
+                       if (plugin->thread != NULL)
+                               if ((error = rdpsnd_virtual_channel_event_disconnected(plugin)))
+                                       WLog_ERR(TAG, "rdpsnd_virtual_channel_event_disconnected failed with error %lu!", error);
                        rdpsnd_virtual_channel_event_terminated(plugin);
                        break;
        }
index 57336ba..aa9367f 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright 2010-2012 Vic Lee
  * Copyright 2015 Thincast Technologies GmbH
  * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
+ * Copyright 2016 David PHAM-VAN <d.phamvan@inuvika.com>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -136,6 +137,7 @@ static void CALLBACK rdpsnd_winmm_callback_function(HWAVEOUT hwo, UINT uMsg, DWO
                                winmm->device.WaveConfirm(&(winmm->device), wave);
 
                                free(lpWaveHdr->lpData);
+                               free(lpWaveHdr);
 
                                free(wave);
                        }
@@ -330,6 +332,7 @@ void rdpsnd_winmm_wave_play(rdpsndDevicePlugin* device, RDPSND_WAVE* wave)
        {
                WLog_ERR(TAG,  "waveOutWrite failure: %d", mmResult);
                waveOutUnprepareHeader(winmm->hWaveOut, lpWaveHdr, sizeof(WAVEHDR));
+               free(lpWaveHdr);
                return;
        }
 }