提交 49dd6d0d 编写于 作者: K Kővágó, Zoltán 提交者: Gerd Hoffmann

paaudio: fix possible resource leak

qpa_audio_init did not clean up resources properly if the initialization
failed. This hopefully fixes it.
Signed-off-by: NKővágó, Zoltán <DirtY.iCE.hu@gmail.com>
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
上级 f2dcc6ce
...@@ -47,6 +47,8 @@ typedef struct { ...@@ -47,6 +47,8 @@ typedef struct {
paaudio *g; paaudio *g;
} PAVoiceIn; } PAVoiceIn;
static void qpa_audio_fini(void *opaque);
static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ...) static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ...)
{ {
va_list ap; va_list ap;
...@@ -814,6 +816,8 @@ static void *qpa_audio_init (void) ...@@ -814,6 +816,8 @@ static void *qpa_audio_init (void)
{ {
paaudio *g = g_malloc(sizeof(paaudio)); paaudio *g = g_malloc(sizeof(paaudio));
g->conf = glob_conf; g->conf = glob_conf;
g->mainloop = NULL;
g->context = NULL;
g->mainloop = pa_threaded_mainloop_new (); g->mainloop = pa_threaded_mainloop_new ();
if (!g->mainloop) { if (!g->mainloop) {
...@@ -867,7 +871,7 @@ unlock_and_fail: ...@@ -867,7 +871,7 @@ unlock_and_fail:
pa_threaded_mainloop_unlock (g->mainloop); pa_threaded_mainloop_unlock (g->mainloop);
fail: fail:
AUD_log (AUDIO_CAP, "Failed to initialize PA context"); AUD_log (AUDIO_CAP, "Failed to initialize PA context");
g_free(g); qpa_audio_fini(g);
return NULL; return NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册