[vlc-devel] [PATCH] win32: thread: Fix module handle leak
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Mon Jun 19 13:46:39 CEST 2017
CID #1446132
---
src/libvlc.h | 1 +
src/win32/specific.c | 1 +
src/win32/thread.c | 10 +++++++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/libvlc.h b/src/libvlc.h
index 15db8e037f..904be85a84 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -40,6 +40,7 @@ extern void vlc_DeinitActions (libvlc_int_t *, struct vlc_actions *);
void system_Init ( void );
void system_Configure ( libvlc_int_t *, int, const char *const [] );
#if defined(_WIN32) || defined(__OS2__)
+void vlc_ReleaseTimerLibrary();
void system_End(void);
#ifndef __OS2__
size_t EnumClockSource( vlc_object_t *, const char *, char ***, char *** );
diff --git a/src/win32/specific.c b/src/win32/specific.c
index c38890febc..56d9fa1c44 100644
--- a/src/win32/specific.c
+++ b/src/win32/specific.c
@@ -186,6 +186,7 @@ void system_Configure( libvlc_int_t *p_this, int i_argc, const char *const ppsz_
*/
void system_End(void)
{
+ vlc_ReleaseTimerLibrary();
/* XXX: In theory, we should not call this if WSAStartup() failed. */
WSACleanup();
}
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 40c294dd52..f5688e20af 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -829,6 +829,8 @@ void (msleep)(mtime_t delay)
}
#endif
+HMODULE hWinmm = INVALID_HANDLE_VALUE;
+
static BOOL SelectClockSource(void *data)
{
vlc_object_t *obj = data;
@@ -878,7 +880,7 @@ static BOOL SelectClockSource(void *data)
TIMECAPS caps;
MMRESULT (WINAPI * timeBeginPeriod)(UINT);
- HMODULE hWinmm = LoadLibrary(TEXT("winmm.dll"));
+ hWinmm = LoadLibrary(TEXT("winmm.dll"));
if (!hWinmm)
goto perf;
@@ -924,6 +926,12 @@ static BOOL SelectClockSource(void *data)
return TRUE;
}
+void vlc_ReleaseTimerLibrary()
+{
+ if (hWinmm != INVALID_HANDLE_VALUE)
+ FreeLibrary(hWinmm);
+}
+
size_t EnumClockSource (vlc_object_t *obj, const char *var,
char ***vp, char ***np)
{
--
2.11.0
More information about the vlc-devel
mailing list