diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2006-02-27 09:54:57 +0000 |
---|---|---|
committer | Clemens Ladisch <clemens@ladisch.de> | 2006-02-27 09:54:57 +0000 |
commit | 45850439b3b28ff7ed0d1455f62f5a85572caefa (patch) | |
tree | b5012ff1a61d61e37555d37d430b7e243fbfa39c /src/seq | |
parent | f9c7321670f2757b02b0f17a0460ce0b39541127 (diff) |
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.
Diffstat (limited to 'src/seq')
-rw-r--r-- | src/seq/seq.c | 4 | ||||
-rw-r--r-- | src/seq/seq_hw.c | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/seq/seq.c b/src/seq/seq.c index df7b64e6..07954a35 100644 --- a/src/seq/seq.c +++ b/src/seq/seq.c @@ -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; } /** diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c index a2a01455..c92f3648 100644 --- a/src/seq/seq_hw.c +++ b/src/seq/seq_hw.c @@ -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) |