[Wine-patches] gdi32: Prevent freeing graphics_driver when it is used by bitmap object (eterbug #4394).
Alexander Morozov
amorozov на etersoft.ru
Пн Дек 14 21:24:49 MSK 2009
----------- следующая часть -----------
From 23ccebadb27019358a6f004e8237b5463a36b636 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Mon, 14 Dec 2009 21:12:45 +0300
Subject: [PATCH] gdi32: Prevent freeing graphics_driver when it is used by bitmap object (eterbug #4394).
---
dlls/gdi32/bitmap.c | 16 +++++++++++++---
dlls/gdi32/dib.c | 2 +-
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c
index 6039f8f..94e0d49 100644
--- a/dlls/gdi32/bitmap.c
+++ b/dlls/gdi32/bitmap.c
@@ -548,14 +548,18 @@ BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, DC *dc )
{
if (dc->funcs->pCreateBitmap) ret = dc->funcs->pCreateBitmap( dc->physDev, hbitmap,
bitmap->bitmap.bmBits );
- if (ret) bitmap->funcs = dc->funcs;
+ if (ret) bitmap->funcs = DRIVER_get_driver( dc->funcs );
}
else if (bitmap->funcs != dc->funcs)
{
FIXME( "Trying to select bitmap %p in different DC type\n", hbitmap );
if (dc->funcs->pCreateBitmap) ret = dc->funcs->pCreateBitmap( dc->physDev, hbitmap,
bitmap->bitmap.bmBits );
- if (ret) bitmap->funcs = dc->funcs;
+ if (ret)
+ {
+ DRIVER_release_driver( bitmap->funcs );
+ bitmap->funcs = DRIVER_get_driver( dc->funcs );
+ }
}
GDI_ReleaseObj( hbitmap );
return ret;
@@ -636,7 +640,13 @@ static BOOL BITMAP_DeleteObject( HGDIOBJ handle )
funcs = bmp->funcs;
GDI_ReleaseObj( handle );
- if (funcs && funcs->pDeleteBitmap) funcs->pDeleteBitmap( handle );
+ if (funcs)
+ {
+ if (funcs->pDeleteBitmap)
+ funcs->pDeleteBitmap( handle );
+ DRIVER_release_driver( funcs );
+ bmp->funcs = NULL;
+ }
if (!(bmp = free_gdi_handle( handle ))) return FALSE;
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 0dceaa8..566d1e9 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -1340,7 +1340,7 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage,
if (ret && ((bmp = GDI_GetObjPtr(ret, OBJ_BITMAP))))
{
bmp->dib = dib;
- bmp->funcs = dc->funcs;
+ bmp->funcs = DRIVER_get_driver( dc->funcs );
/* create local copy of DIB palette */
if (bpp <= 8) DIB_CopyColorTable( dc, bmp, usage, bmi );
GDI_ReleaseObj( ret );
--
1.6.5.6
Подробная информация о списке рассылки Wine-patches