mirror of
https://github.com/reactos/reactos.git
synced 2024-08-02 17:40:58 +00:00
Fixing another memory crash bug this time for GetFourCCCodes
svn path=/trunk/; revision=26864
This commit is contained in:
parent
2a62b56fd9
commit
3355adf732
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
#include "rosdraw.h"
|
#include "rosdraw.h"
|
||||||
|
|
||||||
|
/* PSEH for SEH Support */
|
||||||
|
#include <pseh/pseh.h>
|
||||||
|
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
|
Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
|
||||||
REFIID id,
|
REFIID id,
|
||||||
|
@ -150,26 +153,33 @@ Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD lpNumCodes, LPDWORD
|
||||||
|
|
||||||
DX_WINDBG_trace();
|
DX_WINDBG_trace();
|
||||||
|
|
||||||
/* FIXME protect with SEH or something else if lpCodes or lpNumCodes for bad user pointers */
|
|
||||||
EnterCriticalSection(&ddcs);
|
// EnterCriticalSection(&ddcs);
|
||||||
|
|
||||||
if(!lpNumCodes)
|
_SEH_TRY
|
||||||
{
|
{
|
||||||
retVal = DDERR_INVALIDPARAMS;
|
if(IsBadWritePtr(lpNumCodes,sizeof(LPDWORD)))
|
||||||
|
{
|
||||||
|
retVal = DDERR_INVALIDPARAMS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!IsBadWritePtr(lpCodes,sizeof(LPDWORD)))
|
||||||
|
{
|
||||||
|
memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, sizeof(DWORD)* min(This->lpLcl->lpGbl->dwNumFourCC, *lpNumCodes));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
_SEH_HANDLE
|
||||||
{
|
{
|
||||||
if ((lpCodes) && (*lpCodes))
|
|
||||||
{
|
|
||||||
memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, sizeof(DWORD)* min(This->lpLcl->lpGbl->dwNumFourCC, *lpNumCodes));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_SEH_END;
|
||||||
|
|
||||||
LeaveCriticalSection(&ddcs);
|
//LeaveCriticalSection(&ddcs);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<library>user32</library>
|
<library>user32</library>
|
||||||
<library>advapi32</library>
|
<library>advapi32</library>
|
||||||
<library>msvcrt</library>
|
<library>msvcrt</library>
|
||||||
|
<library>pseh</library>
|
||||||
|
|
||||||
<file>ddraw.rc</file>
|
<file>ddraw.rc</file>
|
||||||
<file>main.c</file>
|
<file>main.c</file>
|
||||||
|
|
Loading…
Reference in a new issue