[vlc-devel] [PATCH] win32: thread: Fix module handle leak

remi at remlab.net remi at remlab.net
Mon Jun 19 15:31:11 CEST 2017


I don't really see the point in unloading a system library, and the patch will lead to UB w/ multiple instances.

Le 19 juin 2017 14:46:39 GMT+03:00, "Hugo Beauzée-Luyssen" <hugo at beauzee.fr> a écrit :
>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
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170619/a533b5d0/attachment.html>


More information about the vlc-devel mailing list