In case the config file does not exist, the function returns NULL
without freeing the config_file buffer.
This patch also makes config_file non-static. As configfile_exists()
is called at most once, it is pointless to have a static variable
there. The condition "if (!config_file)" is always true, so we can
get rid of the conditional alltogether.
static char *configfile_exists(void)
{
- static char *config_file;
+ char *config_file;
struct stat statbuf;
+ char *home = para_homedir();
- if (!config_file) {
- char *home = para_homedir();
- config_file = make_message("%s/.paraslash/audioc.conf", home);
- free(home);
- }
+ config_file = make_message("%s/.paraslash/audioc.conf", home);
+ free(home);
if (!stat(config_file, &statbuf))
return config_file;
+ free(config_file);
return NULL;
}