Do not abort in snd_xxx_close() functions

Remove several memory leaks by not aborting prematurely from a
snd_xxx_close() function when some operation fails.
This can happen when a USB device was unplugged.
This commit is contained in:
Clemens Ladisch 2006-02-27 09:54:57 +00:00
parent f9c7321670
commit 45850439b3
11 changed files with 33 additions and 33 deletions

View file

@ -1029,8 +1029,6 @@ int snd_seq_close(snd_seq_t *seq)
int err;
assert(seq);
err = seq->ops->close(seq);
if (err < 0)
return err;
if (seq->obuf)
free(seq->obuf);
if (seq->ibuf)
@ -1040,7 +1038,7 @@ int snd_seq_close(snd_seq_t *seq)
if (seq->name)
free(seq->name);
free(seq);
return 0;
return err;
}
/**

View file

@ -42,12 +42,14 @@ typedef struct {
static int snd_seq_hw_close(snd_seq_t *seq)
{
snd_seq_hw_t *hw = seq->private_data;
int err = 0;
if (close(hw->fd)) {
err = -errno;
SYSERR("close failed\n");
return -errno;
}
free(hw);
return 0;
return err;
}
static int snd_seq_hw_nonblock(snd_seq_t *seq, int nonblock)