From 828a5f552f5d2cff01e588af7b686099687a7bac Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Sun, 17 Jan 2010 12:03:22 +0100
Subject: output/pulse: clear the "mainloop" attribute on error

When enabling the pulse device fails, clear po->mainloop after
pa_threaded_mainloop_free() has finished.  This is important for the
assertions.

Two wrong g_free() calls were also removed.
---
 src/output/pulse_output_plugin.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/output/pulse_output_plugin.c b/src/output/pulse_output_plugin.c
index 8769fc889..d29fbd705 100644
--- a/src/output/pulse_output_plugin.c
+++ b/src/output/pulse_output_plugin.c
@@ -244,6 +244,7 @@ pulse_output_setup_context(struct pulse_output *po, GError **error_r)
 
 	if (!pulse_output_connect(po, error_r)) {
 		pa_context_unref(po->context);
+		po->context = NULL;
 		return false;
 	}
 
@@ -315,7 +316,7 @@ pulse_output_enable(void *data, GError **error_r)
 	if (pa_threaded_mainloop_start(po->mainloop) < 0) {
 		pa_threaded_mainloop_unlock(po->mainloop);
 		pa_threaded_mainloop_free(po->mainloop);
-		g_free(po);
+		po->mainloop = NULL;
 
 		g_set_error(error_r, pulse_output_quark(), 0,
 			    "pa_threaded_mainloop_start() has failed");
@@ -332,7 +333,7 @@ pulse_output_enable(void *data, GError **error_r)
 		pa_threaded_mainloop_unlock(po->mainloop);
 		pa_threaded_mainloop_stop(po->mainloop);
 		pa_threaded_mainloop_free(po->mainloop);
-		g_free(po);
+		po->mainloop = NULL;
 		return false;
 	}
 
-- 
cgit v1.2.3