[vlc-devel] [PATCH] win32: thread: Fix module handle leak
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Mon Jun 19 14:03:32 CEST 2017
On Mon, Jun 19, 2017, at 01:46 PM, Hugo Beauzée-Luyssen wrote:
> 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
Hi,
As a side note, this CID is not available on the main coverity project,
but on a vlc-win32 one (due to a coverity limitation which doesn't allow
to have different build targets as part of the same project)
If a developer is interested in getting access to this project, feel
free to contact me off list and I'll add you.
Regards,
--
Hugo Beauzée-Luyssen
hugo at beauzee.fr
More information about the vlc-devel
mailing list