mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-13 04:27:44 -05:00
mixer: Fix missing hctl handle free in snd_mixer_attach_hctl()
Yet another missing piece. Also, update the function document to warn about the behavior at error. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
f78ba070b3
commit
7c1f36dbcb
1 changed files with 5 additions and 1 deletions
|
|
@ -214,6 +214,8 @@ int snd_mixer_attach(snd_mixer_t *mixer, const char *name)
|
||||||
* \param mixer Mixer handle
|
* \param mixer Mixer handle
|
||||||
* \param hctl the HCTL to be attached
|
* \param hctl the HCTL to be attached
|
||||||
* \return 0 on success otherwise a negative error code
|
* \return 0 on success otherwise a negative error code
|
||||||
|
*
|
||||||
|
* Upon error, this function closes the given hctl handle automatically.
|
||||||
*/
|
*/
|
||||||
int snd_mixer_attach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl)
|
int snd_mixer_attach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl)
|
||||||
{
|
{
|
||||||
|
|
@ -222,8 +224,10 @@ int snd_mixer_attach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl)
|
||||||
|
|
||||||
assert(hctl);
|
assert(hctl);
|
||||||
slave = calloc(1, sizeof(*slave));
|
slave = calloc(1, sizeof(*slave));
|
||||||
if (slave == NULL)
|
if (slave == NULL) {
|
||||||
|
snd_hctl_close(hctl);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
err = snd_hctl_nonblock(hctl, 1);
|
err = snd_hctl_nonblock(hctl, 1);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
snd_hctl_close(hctl);
|
snd_hctl_close(hctl);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue