oss: Fix double free bug on open failure.
authorAndre Noll <maan@systemlinux.org>
Wed, 12 May 2010 21:22:37 +0000 (23:22 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 12 May 2010 21:22:37 +0000 (23:22 +0200)
If setting the oss parameters (sample format, sample rate, channel
count) fails, we end up freeing the private_oss_data struct twice.

oss_write.c

index 3ef0d9e..4854563 100644 (file)
@@ -82,7 +82,8 @@ static void oss_close(struct writer_node *wn)
 {
        struct private_oss_write_data *powd = wn->private_data;
 
-       close(powd->fd);
+       if (powd->fd >= 0)
+               close(powd->fd);
        free(powd);
 }
 
@@ -175,7 +176,7 @@ static int oss_open(struct writer_node *wn)
        return 1;
 err:
        close(powd->fd);
-       free(powd);
+       powd->fd = -1;
        return ret;
 }