aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/gpgconf-comp.c53
-rw-r--r--tools/gpgconf.c1
-rw-r--r--tools/gpgconf.h4
3 files changed, 52 insertions, 6 deletions
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index 925f1cf2d..2dcf0758e 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -1102,6 +1102,35 @@ struct error_line_s
+
+/* Initialization and finalization. */
+
+static void
+gc_option_free (gc_option_t *o)
+{
+ if (o == NULL || o->name == NULL)
+ return;
+
+ xfree (o->value);
+ gc_option_free (o + 1);
+}
+
+static void
+gc_components_free (void)
+{
+ int i;
+ for (i = 0; i < DIM (gc_component); i++)
+ gc_option_free (gc_component[i].options);
+}
+
+void
+gc_components_init (void)
+{
+ atexit (gc_components_free);
+}
+
+
+
/* Engine specific support. */
static void
gpg_agent_runtime_change (int killflag)
@@ -2183,7 +2212,7 @@ retrieve_options_from_program (gc_component_t component, gc_backend_t backend)
if (!(option->flags & GC_OPT_FLAG_LIST))
{
if (option->value)
- free (option->value);
+ xfree (option->value);
option->value = opt_value;
}
else
@@ -2192,10 +2221,9 @@ retrieve_options_from_program (gc_component_t component, gc_backend_t backend)
option->value = opt_value;
else
{
- char *opt_val = opt_value;
-
- option->value = xasprintf ("%s,%s", option->value,
- opt_val);
+ char *old = option->value;
+ option->value = xasprintf ("%s,%s", old, opt_value);
+ xfree (old);
xfree (opt_value);
}
}
@@ -2872,7 +2900,12 @@ change_options_program (gc_component_t component, gc_backend_t backend,
res = link (dest_filename, orig_filename);
#endif
if (res < 0 && errno != ENOENT)
- return -1;
+ {
+ xfree (dest_filename);
+ xfree (src_filename);
+ xfree (orig_filename);
+ return -1;
+ }
if (res < 0)
{
xfree (orig_filename);
@@ -3365,6 +3398,7 @@ gc_component_change_options (int component, estream_t in, estream_t out,
}
if (err)
break;
+ xfree (src_filename[i]);
src_filename[i] = NULL;
}
}
@@ -3434,10 +3468,17 @@ gc_component_change_options (int component, estream_t in, estream_t out,
unlink (backup_filename);
#endif /* HAVE_W32_SYSTEM */
rename (orig_filename[backend], backup_filename);
+ xfree (backup_filename);
}
leave:
xfree (line);
+ for (backend = 0; backend < GC_BACKEND_NR; backend++)
+ {
+ xfree (src_filename[backend]);
+ xfree (dest_filename[backend]);
+ xfree (orig_filename[backend]);
+ }
}
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index af65424e0..a1034e663 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -470,6 +470,7 @@ main (int argc, char **argv)
/* Make sure that our subsystems are ready. */
i18n_init();
init_common_subsystems (&argc, &argv);
+ gc_components_init ();
/* Parse the command line. */
pargs.argc = &argc;
diff --git a/tools/gpgconf.h b/tools/gpgconf.h
index 39d34b6d0..d6d7627aa 100644
--- a/tools/gpgconf.h
+++ b/tools/gpgconf.h
@@ -38,6 +38,10 @@ struct
/*-- gpgconf-comp.c --*/
+
+/* Initialize the components. */
+void gc_components_init (void);
+
/* Percent-Escape special characters. The string is valid until the
next invocation of the function. */
char *gc_percent_escape (const char *src);