Fix some leaks on a clean boot.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3702 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2021-12-23 20:31:37 +00:00
parent c616a16993
commit efcada8e25

View File

@ -1342,6 +1342,8 @@ static bool _tf_ssb_load_keys(tf_ssb_t* ssb)
return false;
}
bool result = false;
char* json = NULL;
size_t path_size = strlen(home) + strlen(ssb->secrets_path) + 1;
char* path = malloc(path_size);
snprintf(path, path_size, "%s%s", home, ssb->secrets_path);
@ -1350,12 +1352,9 @@ static bool _tf_ssb_load_keys(tf_ssb_t* ssb)
if (!file)
{
printf("Failed to open %s: %s.\n", path, strerror(errno));
return false;
goto failed;
}
char* json = NULL;
bool result = false;
if (fseek(file, 0, SEEK_END) != 0)
{
printf("Failed to seek %s: %s\n.", path, strerror(errno));
@ -1408,7 +1407,10 @@ failed:
{
free(json);
}
fclose(file);
if (file)
{
fclose(file);
}
if (path)
{
free(path);