]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
pulse: rework object destruction paths a bit
authorLennart Poettering <mznyfn@0pointer.de>
Tue, 4 Aug 2009 21:55:28 +0000 (23:55 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 4 Aug 2009 21:58:31 +0000 (23:58 +0200)
Make sure we deal better with partially initialized structs.

Don't check for pointer state before calling free() since free() does
that anyway.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
pulse/ctl_pulse.c
pulse/pcm_pulse.c

index 879f26061c378d37028175a922055ba41b0387b0..85863eded986c459b0bb26d9c9ebb4b5e56e2a04 100644 (file)
@@ -606,11 +606,8 @@ static void pulse_close(snd_ctl_ext_t * ext)
        if (ctl->p)
                pulse_free(ctl->p);
 
-       if (ctl->source)
-               free(ctl->source);
-       if (ctl->sink)
-               free(ctl->sink);
-
+       free(ctl->source);
+       free(ctl->sink);
        free(ctl);
 }
 
index 98983f807131dba30b29c3d2a6962b9e65a1ce71..02a837e6cd263c3a7b692e43742615b564c9f23c 100644 (file)
@@ -819,21 +819,22 @@ static int pulse_close(snd_pcm_ioplug_t * io)
 
        assert(pcm);
 
-       pa_threaded_mainloop_lock(pcm->p->mainloop);
+       if (pcm->p && pcm->p->mainloop) {
 
-       if (pcm->stream) {
-               pa_stream_disconnect(pcm->stream);
-               pa_stream_unref(pcm->stream);
-       }
+               pa_threaded_mainloop_lock(pcm->p->mainloop);
 
-       pa_threaded_mainloop_unlock(pcm->p->mainloop);
+               if (pcm->stream) {
+                       pa_stream_disconnect(pcm->stream);
+                       pa_stream_unref(pcm->stream);
+               }
+
+               pa_threaded_mainloop_unlock(pcm->p->mainloop);
+       }
 
        if (pcm->p)
                pulse_free(pcm->p);
 
-       if (pcm->device)
-               free(pcm->device);
-
+       free(pcm->device);
        free(pcm);
 
        return 0;