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.
Fix Kindred Spirits on the Roof (Steam ID: 402620) crashing at multiple places.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- 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 aad071e8ad..7d324a8b27 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 406e01bf21..98d1ab5a2c 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
Looks good to me, but I think it should be deferred until after 4.0 since it doesn't fix a regression.
Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Wed, Jan 09, 2019 at 10:37:32PM +0800, Zhiyi Zhang wrote:
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.
Fix Kindred Spirits on the Roof (Steam ID: 402620) crashing at multiple places.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com
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 aad071e8ad..7d324a8b27 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 406e01bf21..98d1ab5a2c 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
2.19.2
On 1/10/19 5:42 PM, Andrew Eikum wrote:
Looks good to me, but I think it should be deferred until after 4.0 since it doesn't fix a regression.
Well, bug fixes should be fine at the moment too. A Wine-Bug tag is highly recommended though.
bye michael
Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Wed, Jan 09, 2019 at 10:37:32PM +0800, Zhiyi Zhang wrote:
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.
Fix Kindred Spirits on the Roof (Steam ID: 402620) crashing at multiple places.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com
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 aad071e8ad..7d324a8b27 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 406e01bf21..98d1ab5a2c 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
2.19.2
On Thu, Jan 10, 2019 at 10:00:26PM +0100, Michael Stefaniuc wrote:
On 1/10/19 5:42 PM, Andrew Eikum wrote:
Looks good to me, but I think it should be deferred until after 4.0 since it doesn't fix a regression.
Well, bug fixes should be fine at the moment too. A Wine-Bug tag is highly recommended though.
I admit I don't really understand the rules of code freeze. I thought it was supposed to be only regression fixes, or extremely obvious bug fixes. It seems really weird to me that we accept cleanup patches during code freeze. I don't know, it's not my call.
Andrew