fix: free config & provider after using

This commit is contained in:
Jozef Steinhübl 2024-07-23 18:19:37 +02:00
parent 4c3271703d
commit c4222ac9e6
No known key found for this signature in database
GPG key ID: E6BC90C91973B08F

View file

@ -29,7 +29,6 @@ int provider_info(int argc, char **argv) {
ASSERT_CONFIG_EXIST(cfg); ASSERT_CONFIG_EXIST(cfg);
struct gimi_config_provider *provider = config_find_provider(cfg, argv[1]); struct gimi_config_provider *provider = config_find_provider(cfg, argv[1]);
config_free(cfg);
if (!provider) { if (!provider) {
printf("error: no such provider '%s'", argv[1]); printf("error: no such provider '%s'", argv[1]);
@ -40,6 +39,7 @@ int provider_info(int argc, char **argv) {
printf("ssh: %s\n", provider->ssh); printf("ssh: %s\n", provider->ssh);
printf("primary: %d\n", provider->primary); printf("primary: %d\n", provider->primary);
config_free(cfg);
free(provider); free(provider);
return 0; return 0;
@ -55,7 +55,6 @@ int provider_sync(int argc, char **argv) {
ASSERT_CONFIG_EXIST(cfg); ASSERT_CONFIG_EXIST(cfg);
struct gimi_config_provider *provider = config_find_provider(cfg, argv[1]); struct gimi_config_provider *provider = config_find_provider(cfg, argv[1]);
config_free(cfg);
char command[100]; char command[100];
snprintf(command, sizeof(command), "git remote add gimi-%s %s", snprintf(command, sizeof(command), "git remote add gimi-%s %s",
@ -70,6 +69,9 @@ int provider_sync(int argc, char **argv) {
provider->name); provider->name);
} }
config_free(cfg);
free(provider);
return 0; return 0;
} }