summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-08-25 15:45:57 +0200
committerwm4 <wm4@nowhere>2015-08-25 15:45:57 +0200
commitcf94fce4670cc43a805f8ab90e5f805cb57ff310 (patch)
treec97ae20a7aa327c9a26e09406cc1525fd5ff5886
parent1ec1b4186c87ee88a0bc953c1ea0c5a2bc0f387e (diff)
downloadmpv-cf94fce4670cc43a805f8ab90e5f805cb57ff310.tar.bz2
mpv-cf94fce4670cc43a805f8ab90e5f805cb57ff310.tar.xz
ao_alsa: fix minor memory leak
So snd_device_name_get_hint() return values do in fact have to be freed. Also, change listing semantics slightly: if io==NULL, skip the entry, instead of assuming it's an output device.
-rw-r--r--audio/out/ao_alsa.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index d81df23f9d..b32dceb689 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -923,15 +923,18 @@ static void list_devs(struct ao *ao, struct ao_device_list *list)
char *name = snd_device_name_get_hint(hints[n], "NAME");
char *desc = snd_device_name_get_hint(hints[n], "DESC");
char *io = snd_device_name_get_hint(hints[n], "IOID");
- if (io && strcmp(io, "Output") != 0)
- continue;
- char desc2[1024];
- snprintf(desc2, sizeof(desc2), "%s", desc ? desc : "");
- for (int i = 0; desc2[i]; i++) {
- if (desc2[i] == '\n')
- desc2[i] = '/';
+ if (io && strcmp(io, "Output") == 0) {
+ char desc2[1024];
+ snprintf(desc2, sizeof(desc2), "%s", desc ? desc : "");
+ for (int i = 0; desc2[i]; i++) {
+ if (desc2[i] == '\n')
+ desc2[i] = '/';
+ }
+ ao_device_list_add(list, ao, &(struct ao_device_desc){name, desc2});
}
- ao_device_list_add(list, ao, &(struct ao_device_desc){name, desc2});
+ free(name);
+ free(desc);
+ free(io);
}
snd_device_name_free_hint(hints);