Zhiyi Zhang : msacm32: Reference count local drivers.
Alexandre Julliard
julliard at winehq.org
Mon Jan 28 16:16:59 CST 2019
Module: wine
Branch: master
Commit: bbdf6d5e21cfe1ef5e317d01978310bac614e6a0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bbdf6d5e21cfe1ef5e317d01978310bac614e6a0
Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date: Sat Jan 26 16:20:10 2019 +0800
msacm32: Reference count local drivers.
One local driver can be assigned to multiple driver ids.
When releasing the driver id, check if the reference count
of a local driver is one before actually releasing the local driver.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46520
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msacm32/internal.c | 12 +++++++++++-
dlls/msacm32/wineacm.h | 1 +
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/msacm32/internal.c b/dlls/msacm32/internal.c
index aad071e..7d324a8 100644
--- a/dlls/msacm32/internal.c
+++ b/dlls/msacm32/internal.c
@@ -737,12 +737,17 @@ static PWINE_ACMLOCALDRIVER MSACM_pLastACMLocalDriver;
static PWINE_ACMLOCALDRIVER MSACM_UnregisterLocalDriver(PWINE_ACMLOCALDRIVER paldrv)
{
PWINE_ACMLOCALDRIVER pNextACMLocalDriver;
+ LONG ref;
if (paldrv->pACMInstList) {
ERR("local driver instances still present after closing all drivers - memory leak\n");
return NULL;
}
+ ref = InterlockedDecrement(&paldrv->ref);
+ if (ref)
+ return paldrv;
+
if (paldrv == MSACM_pFirstACMLocalDriver)
MSACM_pFirstACMLocalDriver = paldrv->pNextACMLocalDrv;
if (paldrv == MSACM_pLastACMLocalDriver)
@@ -883,7 +888,11 @@ PWINE_ACMLOCALDRIVER MSACM_RegisterLocalDriver(HMODULE hModule, DRIVERPROC lpDri
/* look up previous instance of local driver module */
for (paldrv = MSACM_pFirstACMLocalDriver; paldrv; paldrv = paldrv->pNextACMLocalDrv)
{
- if (paldrv->hModule == hModule && paldrv->lpDrvProc == lpDriverProc) return paldrv;
+ if (paldrv->hModule == hModule && paldrv->lpDrvProc == lpDriverProc)
+ {
+ InterlockedIncrement(&paldrv->ref);
+ return paldrv;
+ }
}
paldrv = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMLOCALDRIVER));
@@ -892,6 +901,7 @@ PWINE_ACMLOCALDRIVER MSACM_RegisterLocalDriver(HMODULE hModule, DRIVERPROC lpDri
paldrv->hModule = hModule;
paldrv->lpDrvProc = lpDriverProc;
paldrv->pACMInstList = NULL;
+ paldrv->ref = 1;
paldrv->pNextACMLocalDrv = NULL;
paldrv->pPrevACMLocalDrv = MSACM_pLastACMLocalDriver;
diff --git a/dlls/msacm32/wineacm.h b/dlls/msacm32/wineacm.h
index 406e01b..98d1ab5 100644
--- a/dlls/msacm32/wineacm.h
+++ b/dlls/msacm32/wineacm.h
@@ -52,6 +52,7 @@ typedef struct _WINE_ACMLOCALDRIVER
PWINE_ACMLOCALDRIVERINST pACMInstList;
PWINE_ACMLOCALDRIVER pNextACMLocalDrv;
PWINE_ACMLOCALDRIVER pPrevACMLocalDrv;
+ LONG ref;
} WINE_ACMLOCALDRIVER;
typedef struct _WINE_ACMLOCALDRIVERINST
More information about the wine-cvs
mailing list