1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 11:53:26 +01:00

Fix for another segfault/leak case when using -f arg

This commit is contained in:
naxuroqa 2013-08-14 19:21:36 +02:00
parent 9cabdaa6a0
commit cab4d43889

26
main.c
View File

@ -196,17 +196,8 @@ static void load_data(Messenger *m, char *path)
int main(int argc, char *argv[])
{
char *user_config_dir = get_user_config_dir();
char *DATA_FILE;
int config_err = create_user_config_dir(user_config_dir);
if(config_err) {
DATA_FILE = "data";
} else {
DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1);
strcpy(DATA_FILE, user_config_dir);
strcat(DATA_FILE, CONFIGDIR);
strcat(DATA_FILE, "data");
}
free(user_config_dir);
char *DATA_FILE = NULL;
int config_err = 0;
/* This is broken */
int f_loadfromfile = 1;
@ -227,6 +218,19 @@ int main(int argc, char *argv[])
}
}
if (DATA_FILE == NULL ) {
config_err = create_user_config_dir(user_config_dir);
if (config_err) {
DATA_FILE = strdup("data");
} else {
DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1);
strcpy(DATA_FILE, user_config_dir);
strcat(DATA_FILE, CONFIGDIR);
strcat(DATA_FILE, "data");
}
}
free(user_config_dir);
init_term();
Messenger *m = init_tox();
ToxWindow * prompt = init_windows(m);