From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2H4K-0001vS-H4 for qemu-devel@nongnu.org; Tue, 09 Jun 2015 06:47:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2H4I-0004eA-C5 for qemu-devel@nongnu.org; Tue, 09 Jun 2015 06:47:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2H4I-0004dp-78 for qemu-devel@nongnu.org; Tue, 09 Jun 2015 06:47:42 -0400 From: Gerd Hoffmann Date: Tue, 9 Jun 2015 12:47:28 +0200 Message-Id: <1433846851-20552-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1433846851-20552-1-git-send-email-kraxel@redhat.com> References: <1433846851-20552-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 09/12] paaudio: fix possible resource leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Vassili Karpov (malc)" , 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