]> git.tue.mpg.de Git - paraslash.git/commitdiff
Fix oss_init() error path.
authorAndre Noll <maan@systemlinux.org>
Sun, 20 Feb 2011 18:56:59 +0000 (19:56 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 20 Feb 2011 19:27:25 +0000 (20:27 +0100)
A bug similar to the one fixed in the previous patch for the alsa
writer is also present in the oss writer: If oss_init() fails the
->private_data pointer is non-NULL, but its contents have already
been freed. glibc detects this, aborts the process and spits out

*** glibc detected *** ./para_write: double free or corruption (fasttop): 0x080622a0 ***

Fix this bug by initializing ->private_data only if oss_init()
succeeds.

oss_write.c

index df9608a8c6a2bbb9b3787df76ce8ec7931604e16..70a58203db8a2f2e3eca5cfc12506334ed7133da 100644 (file)
@@ -88,7 +88,6 @@ static int oss_init(struct writer_node *wn, unsigned sample_rate,
        struct oss_write_args_info *conf = wn->conf;
        struct private_oss_write_data *powd = para_calloc(sizeof(*powd));
 
-       wn->private_data = powd;
        PARA_INFO_LOG("opening %s\n", conf->device_arg);
        ret = para_open(conf->device_arg, O_WRONLY, 0);
        if (ret < 0)
@@ -149,6 +148,7 @@ static int oss_init(struct writer_node *wn, unsigned sample_rate,
                        sample_rate);
        }
        wn->min_iqs = powd->bytes_per_frame;
+       wn->private_data = powd;
        return 1;
 err:
        close(powd->fd);