From a5f0e0b2f7897fc6ef1ab847146e16ef64d1d4a7 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 26 Apr 2024 15:28:01 +0200 Subject: argparse: Fix a theoretical memory leak. * src/argparse.c (store_alias): Free NAME because it has ownerhip here. Take care P is actually a pointer into NAME. -- Note that aliases have never been implemented. GnuPG-bug-id: 7105 --- src/argparse.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/argparse.c b/src/argparse.c index 106e818..c59e5b2 100644 --- a/src/argparse.c +++ b/src/argparse.c @@ -578,12 +578,12 @@ initialize (gpgrt_argparse_t *arg, gpgrt_opt_t *opts, estream_t fp) static void store_alias( gpgrt_argparse_t *arg, char *name, char *value ) { - /* TODO: replace this dummy function with a rea one - * and fix the probelms IRIX has with (ALIAS_DEV)arg.. + /* TODO: replace this dummy function with a real one + * and fix the problems IRIX has with (ALIAS_DEV)arg.. * used as lvalue */ (void)arg; - (void)name; + xfree (name); (void)value; #if 0 ALIAS_DEF a = xmalloc( sizeof *a ); @@ -1843,6 +1843,7 @@ _gpgrt_argparse (estream_t fp, gpgrt_argparse_t *arg, gpgrt_opt_t *opts_orig) *p++ = 0; trim_spaces (p); } + if (!p || !*p) { xfree (buffer); -- cgit v1.2.3