]> git.sesse.net Git - vlc/commitdiff
auhal: don't leak the device list
authorFelix Paul Kühne <fkuehne@videolan.org>
Sat, 16 Feb 2013 20:12:51 +0000 (21:12 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sat, 16 Feb 2013 20:12:51 +0000 (21:12 +0100)
modules/audio_output/auhal.c

index 18a0d5aea77b3798806f4494d3f7e64e8d5e70a8..d56e07555ddf9f97ce01a85bc2cfb27eaa04d941 100644 (file)
@@ -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);