From 6eb4ff6212f949228ed7031fa56e14031e1b997b Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 17 Oct 2023 12:59:37 +0200 Subject: [PATCH] [server,proxy] fix pf_context_copy_settings possible memory leaks in failure case fixed --- server/proxy/pf_context.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/server/proxy/pf_context.c b/server/proxy/pf_context.c index 7b0dbd445..9a476d8f0 100644 --- a/server/proxy/pf_context.c +++ b/server/proxy/pf_context.c @@ -237,27 +237,21 @@ BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src) return FALSE; if (!freerdp_settings_copy(dst, src)) - { - freerdp_settings_free(before_copy); - return FALSE; - } + goto out_fail; /* keep original ServerMode value */ if (!freerdp_settings_copy_item(dst, before_copy, FreeRDP_ServerMode)) - { - freerdp_settings_free(before_copy); - return FALSE; - } + goto out_fail; /* revert some values that must not be changed */ if (!pf_context_revert_str_settings(dst, before_copy, ARRAYSIZE(to_revert), to_revert)) - return FALSE; + goto out_fail; if (!freerdp_settings_get_bool(dst, FreeRDP_ServerMode)) { /* adjust instance pointer */ if (!freerdp_settings_copy_item(dst, before_copy, FreeRDP_instance)) - return FALSE; + goto out_fail; /* * RdpServerRsaKey must be set to NULL if `dst` is client's context