Received: from eggs.gnu.org ([2001:4830:134:3::10]:49103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TUy-0006jH-SP for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4TUx-00061O-JM for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TUx-00060c-4F for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:19 -0400 From: Gerd Hoffmann Date: Mon, 15 Jun 2015 14:28:01 +0200 Message-Id: <1434371291-6994-11-git-send-email-kraxel@redhat.com> In-Reply-To: <1434371291-6994-1-git-send-email-kraxel@redhat.com> References: <1434371291-6994-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 10/20] paaudio: fix possible resource leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= From: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n qpa_audio_init did not clean up resources properly if the initialization failed. This hopefully fixes it. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 35e8887..fea6071 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -47,6 +47,8 @@ typedef struct { paaudio *g; } PAVoiceIn; =20 +static void qpa_audio_fini(void *opaque); + static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ..= .) { va_list ap; @@ -814,6 +816,8 @@ static void *qpa_audio_init (void) { paaudio *g =3D g_malloc(sizeof(paaudio)); g->conf =3D glob_conf; + g->mainloop =3D NULL; + g->context =3D NULL; =20 g->mainloop =3D pa_threaded_mainloop_new (); if (!g->mainloop) { @@ -867,7 +871,7 @@ unlock_and_fail: pa_threaded_mainloop_unlock (g->mainloop); fail: AUD_log (AUDIO_CAP, "Failed to initialize PA context"); - g_free(g); + qpa_audio_fini(g); return NULL; } =20 --=20 1.8.3.1