server: proxy: fix leak in pf_context_copy_settings
authorKobi Mizrachi <kmizrachi18@gmail.com>
Thu, 2 Jan 2020 13:19:08 +0000 (15:19 +0200)
committerakallabeth <akallabeth@users.noreply.github.com>
Mon, 13 Jan 2020 12:41:44 +0000 (13:41 +0100)
server/proxy/pf_context.c

index 56cb671..76e1a02 100644 (file)
@@ -131,7 +131,15 @@ BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src)
        {
                /* adjust instance pointer for client's context */
                dst->instance = before_copy->instance;
-               /* RdpServerRsaKey must be set to NULL if `dst` is client's context */
+
+               /*
+                * RdpServerRsaKey must be set to NULL if `dst` is client's context
+                * it must be freed before setting it to NULL to avoid a memory leak!
+                */
+
+               free(dst->RdpServerRsaKey->Modulus);
+               free(dst->RdpServerRsaKey->PrivateExponent);
+               free(dst->RdpServerRsaKey);
                dst->RdpServerRsaKey = NULL;
        }