mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fix configfile memory leaks
This commit is contained in:
parent
8a83d2a973
commit
5b7191ed7c
1 changed files with 9 additions and 1 deletions
|
|
@ -236,18 +236,26 @@ static int resolve_config_file(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(c->path);
|
||||||
|
|
||||||
asprintf(&c->path, "%s/.config/tio/tiorc", getenv("HOME"));
|
asprintf(&c->path, "%s/.config/tio/tiorc", getenv("HOME"));
|
||||||
if (!access(c->path, F_OK))
|
if (!access(c->path, F_OK))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(c->path);
|
||||||
|
|
||||||
asprintf(&c->path, "%s/.tiorc", getenv("HOME"));
|
asprintf(&c->path, "%s/.tiorc", getenv("HOME"));
|
||||||
if (!access(c->path, F_OK))
|
if (!access(c->path, F_OK))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(c->path);
|
||||||
|
|
||||||
|
c->path = NULL;
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -333,7 +341,7 @@ void config_file_print()
|
||||||
tio_printf(" Path: %s", c->path);
|
tio_printf(" Path: %s", c->path);
|
||||||
if (c->section_name != NULL)
|
if (c->section_name != NULL)
|
||||||
{
|
{
|
||||||
tio_printf(" Active config section: %s", c->section_name);
|
tio_printf(" Active sub-configuration: %s", c->section_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue