From 64933bf444fd83a6f04a1a13f0b2a67caa43a2cb Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Fri, 9 Jun 2017 00:04:36 +0200 Subject: [PATCH] Fix memory leak in add_option() for option 'connection' This patch ensures that if an error occurs while processing the 'connection' directive of an options specification, the variable 'struct options sub', which is initialized with init_options(), is properly freed with uninit_options(). Signed-off-by: Guido Vranken Acked-by: Gert Doering Message-Id: URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14764.html Signed-off-by: Gert Doering (cherry picked from commit d89e14d92623731d2fa6343a11072caab32e13cd) --- src/openvpn/options.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 79f861bf6..32b4961ba 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -4565,12 +4565,16 @@ add_option (struct options *options, if (!sub.ce.remote) { msg (msglevel, "Each 'connection' block must contain exactly one 'remote' directive"); + uninit_options (&sub); goto err; } e = alloc_connection_entry (options, msglevel); if (!e) - goto err; + { + uninit_options (&sub); + goto err; + } *e = sub.ce; gc_transfer (&options->gc, &sub.gc); uninit_options (&sub); -- 2.47.2