From efcada8e2576ec6a13b363579e7a3e7d4c64666f Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 23 Dec 2021 20:31:37 +0000 Subject: [PATCH] Fix some leaks on a clean boot. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3702 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/ssb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ssb.c b/src/ssb.c index 5e7c4d79..8453f7d5 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -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);