Fixing another memory crash bug this time for GetFourCCCodes

svn path=/trunk/; revision=26860
This commit is contained in:
Magnus Olsen 2007-05-21 20:51:55 +00:00
parent 3893f07116
commit d746c66d94
2 changed files with 21 additions and 16 deletions

View file

@ -146,28 +146,31 @@ HRESULT WINAPI
Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD lpNumCodes, LPDWORD lpCodes)
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
HRESULT retVal = DD_OK;
DX_WINDBG_trace();
/* FIXME protect with SEH or something else if lpCodes or lpNumCodes for bad user pointers */
EnterCriticalSection(&ddcs);
if(!lpNumCodes)
{
LeaveCriticalSection(&ddcs);
return DDERR_INVALIDPARAMS;
}
if(lpCodes)
{
memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, sizeof(DWORD)* min(This->lpLcl->lpGbl->dwNumFourCC, *lpNumCodes));
}
else
{
*lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
}
if(!lpNumCodes)
{
retVal = DDERR_INVALIDPARAMS;
}
else
{
if ((lpCodes) && (*lpCodes))
{
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;
return retVal;
}
HRESULT WINAPI

View file

@ -188,7 +188,7 @@ StartDirectDraw(LPDIRECTDRAW iface, LPGUID lpGuid, BOOL reenable)
if (reenable == FALSE)
{
if (This->lpLink == NULL)
if ((!IsBadReadPtr(This->lpLink,sizeof(LPDIRECTDRAW))) && (This->lpLink == NULL))
{
RtlZeroMemory(&ddgbl, sizeof(DDRAWI_DIRECTDRAW_GBL));
This->lpLcl->lpGbl->dwRefCnt++;
@ -470,6 +470,8 @@ StartDirectDrawHal(LPDIRECTDRAW iface, BOOL reenable)
// FIXME Close DX fristcall and second call
return DD_FALSE;
}
DX_STUB_str("Here\n");
/* Alloc mpFourCC */
mpFourCC = NULL;