Browse Source

Fix memory leak in PLAP

When LogonUI unloads and reloads the PLAP dll, or when the provider
is released and re-created, memory allocated for config list and
groups leak.

- Fix by freeing config list and groups in DeleteUI

We do not call this before exiting WinMain in the GUI code,
as its hard to do it safely -- have to ensure all status
threads have terminated. Anyway, freeing is only cosmetic in this case.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/608/head
Selva Nair 2 years ago
parent
commit
aaeb8d2700
  1. 15
      openvpn_config.c
  2. 3
      openvpn_config.h
  3. 2
      plap/ui_glue.c

15
openvpn_config.c

@ -466,3 +466,18 @@ BuildFileList()
issue_warnings = false;
}
void
FreeConfigList(options_t *o)
{
connection_t *next = NULL;
for (connection_t *c = o->chead; c; c = next)
{
next = c->next;
free(c);
}
free(o->groups);
o->groups = NULL;
o->num_configs = 0;
o->num_groups = 0;
}

3
openvpn_config.h

@ -24,7 +24,8 @@
#include "main.h"
void BuildFileList();
void BuildFileList(void);
bool ConfigFileOptionExist(int, const char *);
void FreeConfigList(options_t *o);
#endif

2
plap/ui_glue.c

@ -438,6 +438,8 @@ DeleteUI(void)
dmsg(L"DeleteUI called before InitializeUI");
}
DetachAllOpenVPN();
/* at this point all status threads have terminated -- we can safely free config list */
FreeConfigList(&o);
CloseSemaphore(o.session_semaphore);
WSACleanup();
memset (&o, 0, sizeof(o));

Loading…
Cancel
Save