From 15ef3f5772ba96b89d48c0cd89e8efab16da346d Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Sun, 6 Feb 2022 18:01:41 -0800 Subject: [PATCH] Fix memory leak in pulse.c This issue was hidden by the oversight of Legacy IPv4 split routes in 3d845bc9b, which was subsequently fixed in https://gitlab.com/openconnect/openconnect/-/merge_requests/330 / 52d1c674. Signed-off-by: Daniel Lenski --- pulse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pulse.c b/pulse.c index d0e2fec0..0d7fca19 100644 --- a/pulse.c +++ b/pulse.c @@ -2259,6 +2259,9 @@ static int handle_main_config_packet(struct openconnect_info *vpninfo, int l; unsigned char *p; + struct oc_vpn_option *new_opts = NULL; + struct oc_ip_info new_ip_info = {}; + /* First part of header, similar to ESP, has already been checked */ if (len < 0x31 || /* Start of routing information */ @@ -2273,14 +2276,13 @@ static int handle_main_config_packet(struct openconnect_info *vpninfo, vpn_progress(vpninfo, PRG_ERR, _("Unexpected Pulse config packet:\n")); dump_buf_hex(vpninfo, PRG_ERR, '<', (void *)bytes, len); + free_optlist(new_opts); + free_split_routes(&new_ip_info); return -EINVAL; } p = bytes + 0x34; routes_len -= 8; /* The header including length and number of routes */ - struct oc_vpn_option *new_opts = NULL; - struct oc_ip_info new_ip_info = {}; - /* We know it's a multiple of 0x10 now. We checked. */ while (routes_len) { char buf[80]; -- 2.50.1