cron2 has submitted this change. ( 
http://gerrit.openvpn.net/c/openvpn/+/1670?usp=email )

Change subject: openvpnserv: Fix memory leak when loading DLLs
......................................................................

openvpnserv: Fix memory leak when loading DLLs

Identified by cppcheck.

Change-Id: Iad3f0c36ac3795fa6a13f2d63bd00ad9c2c30d48
Signed-off-by: Frank Lichtenheld <[email protected]>
Acked-by: Heiko Hund <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1670
Message-Id: <[email protected]>
URL: 
https://www.mail-archive.com/[email protected]/msg36913.html
Signed-off-by: Gert Doering <[email protected]>
---
M src/openvpnserv/interactive.c
1 file changed, 14 insertions(+), 6 deletions(-)




diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index 164f1bf..7726bc9 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -1071,6 +1071,7 @@
     publish_fn_t RtlPublishWnfStateData;
     const DWORD WNF_GPOL_SYSTEM_CHANGES_HI = 0x0D891E2A;
     const DWORD WNF_GPOL_SYSTEM_CHANGES_LO = 0xA3BC0875;
+    BOOL ret = FALSE;

     HMODULE ntdll = LoadLibraryA("ntdll.dll");
     if (ntdll == NULL)
@@ -1081,16 +1082,19 @@
     RtlPublishWnfStateData = (publish_fn_t)GetProcAddress(ntdll, 
"RtlPublishWnfStateData");
     if (RtlPublishWnfStateData == NULL)
     {
-        return FALSE;
+        goto cleanup;
     }

     if (RtlPublishWnfStateData(WNF_GPOL_SYSTEM_CHANGES_LO, 
WNF_GPOL_SYSTEM_CHANGES_HI, 0, 0, 0, 0)
         != ERROR_SUCCESS)
     {
-        return FALSE;
+        goto cleanup;
     }

-    return TRUE;
+    ret = TRUE;
+cleanup:
+    FreeLibrary(ntdll);
+    return ret;
 }

 /**
@@ -1106,6 +1110,7 @@
                                      unsigned int Length, INT64 ExplicitScope);
     publish_fn_t RtlPublishWnfStateData;
     const INT64 WNF_GPOL_SYSTEM_CHANGES = 0x0D891E2AA3BC0875;
+    BOOL ret = FALSE;

     HMODULE ntdll = LoadLibraryA("ntdll.dll");
     if (ntdll == NULL)
@@ -1116,15 +1121,18 @@
     RtlPublishWnfStateData = (publish_fn_t)GetProcAddress(ntdll, 
"RtlPublishWnfStateData");
     if (RtlPublishWnfStateData == NULL)
     {
-        return FALSE;
+        goto cleanup;
     }

     if (RtlPublishWnfStateData(WNF_GPOL_SYSTEM_CHANGES, 0, 0, 0, 0) != 
ERROR_SUCCESS)
     {
-        return FALSE;
+        goto cleanup;
     }

-    return TRUE;
+    ret = TRUE;
+cleanup:
+    FreeLibrary(ntdll);
+    return ret;
 }

 /**

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1670?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iad3f0c36ac3795fa6a13f2d63bd00ad9c2c30d48
Gerrit-Change-Number: 1670
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: d12fk <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to