From: Andre Noll Date: Tue, 4 Sep 2007 20:16:06 +0000 (+0200) Subject: audiod: Fix a memory leak. X-Git-Tag: v0.2.17~15 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=64e19e1bdabc9bb04941f285fb828a8317359816;hp=61b0a431ca3c5dabfa5445355664f00e312c5299 audiod: Fix a memory leak. If the config file doesn't exist, configfile_exists() returnes NULL. The old code leaked a pointer to the config file in this case. This function is only called once at startup, so the leak is benign. Morover, kill the static variable and the check if (!config_file) which is always true. --- diff --git a/audiod.c b/audiod.c index 397ef9a2..dd723233 100644 --- a/audiod.c +++ b/audiod.c @@ -168,14 +168,14 @@ void para_log(int ll, const char* fmt,...) static char *configfile_exists(void) { - static char *config_file; - - if (!config_file) { - char *home = para_homedir(); - config_file = make_message("%s/.paraslash/audiod.conf", home); - free(home); - } - return file_exists(config_file)? config_file : NULL; + char *home = para_homedir(); + char *config_file = make_message("%s/.paraslash/audiod.conf", + home); + free(home); + if (file_exists(config_file)) + return config_file; + free(config_file); + return NULL; } static void setup_signal_handling(void)