Commit 4769197f authored by antma's avatar antma

fix small memory leak in running_for_first_time (local variable config_directory)

parent 83af542d
...@@ -143,12 +143,7 @@ char *get_home_directory (void) { ...@@ -143,12 +143,7 @@ char *get_home_directory (void) {
char *get_config_directory (void) { char *get_config_directory (void) {
char *config_directory; char *config_directory;
int length = strlen (get_home_directory ()) + strlen (CONFIG_DIRECTORY) + 2; assert (asprintf (&config_directory, "%s/" CONFIG_DIRECTORY, get_home_directory ()) >= 0);
config_directory = (char *) calloc (length, sizeof (char));
sprintf (config_directory, "%s/" CONFIG_DIRECTORY,
get_home_directory ());
return config_directory; return config_directory;
} }
...@@ -201,6 +196,8 @@ void running_for_first_time (void) { ...@@ -201,6 +196,8 @@ void running_for_first_time (void) {
printf ("[%s] created\n", config_directory); printf ("[%s] created\n", config_directory);
} }
free (config_directory);
config_directory = NULL;
// see if config file is there // see if config file is there
if (stat (config_filename, &config_file_stat) != 0) { if (stat (config_filename, &config_file_stat) != 0) {
// config file missing, so touch it // config file missing, so touch it
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment