From 813da313d44129d58580d659fbacfbb6febbc2e7 Mon Sep 17 00:00:00 2001 From: Maarten Bosma Date: Mon, 21 May 2007 17:18:41 +0000 Subject: [PATCH] =?UTF-8?q?-=20Also=20leave=20critical=20section=20if=20lp?= =?UTF-8?q?NumCodes=20is=200=20-=20make=20sure=20we=20do=20not=20copy=20to?= =?UTF-8?q?o=20much=20-=20thanks=20to=20Herv=C3=A9=20-=20check=20if=20wind?= =?UTF-8?q?ow=20is=20valid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=26854 --- reactos/dll/directx/ddraw/Ddraw/ddraw_main.c | 12 +++++++++--- .../directx/ddraw/Ddraw/ddraw_setcooperativelevel.c | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c b/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c index b9b09bada08..2a7a6051c8c 100644 --- a/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c +++ b/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c @@ -152,13 +152,19 @@ Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD lpNumCodes, LPDWORD EnterCriticalSection(&ddcs); if(!lpNumCodes) + { + LeaveCriticalSection(&ddcs); return DDERR_INVALIDPARAMS; + } if(lpCodes) - memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, sizeof(DWORD)*(*lpNumCodes)); - else + { + memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, sizeof(DWORD)* MIN(This->lpLcl->lpGbl->dwNumFourCC, *lpNumCodes)); + } + else + { *lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC; - + } LeaveCriticalSection(&ddcs); return DD_OK; diff --git a/reactos/dll/directx/ddraw/Ddraw/ddraw_setcooperativelevel.c b/reactos/dll/directx/ddraw/Ddraw/ddraw_setcooperativelevel.c index be767b449d0..43808d2ea9d 100644 --- a/reactos/dll/directx/ddraw/Ddraw/ddraw_setcooperativelevel.c +++ b/reactos/dll/directx/ddraw/Ddraw/ddraw_setcooperativelevel.c @@ -33,6 +33,9 @@ Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD coopl } #endif + if(hwnd && IsWindow(hwnd)) + return DDERR_INVALIDPARAMS; + /* Tests suggest that we need one of them: */ if(!(cooplevel & (DDSCL_SETFOCUSWINDOW | DDSCL_NORMAL |