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);