mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fix for another segfault/leak case when using -f arg
This commit is contained in:
parent
95664357d4
commit
1b2ac061ec
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user