[vlc-commits] auhal: don't leak the device list

Felix Paul Kühne git at videolan.org
Sat Feb 16 21:14:01 CET 2013


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Feb 16 21:12:51 2013 +0100| [8aeca915c601d1a2008fd8e2e092ea12efd7b2e9] | committer: Felix Paul Kühne

auhal: don't leak the device list

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8aeca915c601d1a2008fd8e2e092ea12efd7b2e9
---

 modules/audio_output/auhal.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 18a0d5a..d56e075 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -942,8 +942,13 @@ static void RebuildDeviceList(audio_output_t * p_aout)
 
     struct aout_sys_t   *p_sys = p_aout->sys;
 
-    if (p_sys->devices)
-        free(p_sys->devices);
+    if (p_sys->devices) {
+        for (struct audio_device_t * device = p_sys->devices, *next; device != NULL; device = next) {
+            next = device->next;
+            free(device->name);
+            free(device);
+        }
+    }
 
     /* Get number of devices */
     AudioObjectPropertyAddress audioDevicesAddress = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
@@ -1550,6 +1555,12 @@ static void Close(vlc_object_t *obj)
     audio_output_t *aout = (audio_output_t *)obj;
     aout_sys_t *sys = aout->sys;
 
+    for (struct audio_device_t * device = sys->devices, *next; device != NULL; device = next) {
+        next = device->next;
+        free(device->name);
+        free(device);
+    }
+
     vlc_mutex_destroy(&sys->lock);
 
     free(sys);



More information about the vlc-commits mailing list