From 6feababc50059e89322f627a6d8077054d27d830 Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Sat, 7 May 2011 19:14:57 +0200 Subject: [PATCH] OOps :) Viva i potenziali segmentation fault! :D --- audio_switcher.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/audio_switcher.c b/audio_switcher.c index ff00888..2f83fd4 100644 --- a/audio_switcher.c +++ b/audio_switcher.c @@ -25,7 +25,7 @@ success_callback(pa_context *c, int success, char* new_output) GError* error = NULL; char *title, *body; - body = (char*) malloc(sizeof(char) * 255); + /* Set messages of the notification based on the success * of the switching operation */ @@ -37,6 +37,7 @@ success_callback(pa_context *c, int success, char* new_output) else { title = "Audio switched"; + body = (char*) malloc(sizeof(char) * 255); if (strlen(new_output) < 235) sprintf(body, "New active output: %s", new_output); else @@ -51,7 +52,8 @@ success_callback(pa_context *c, int success, char* new_output) &error); /* Free vars */ - free (body); + if (success) + free (body); /* Exit the pulseaudio mainloop */ pa_mainloop_quit(mainloop, success); -- 2.1.4