make the cleanup working as it should, do not crash when it try free unlinked dd interface.

svn path=/trunk/; revision=25158
This commit is contained in:
Magnus Olsen 2006-12-14 10:53:35 +00:00
parent 80f2505753
commit 75f5b641f2
2 changed files with 12 additions and 8 deletions

View file

@ -17,6 +17,8 @@ Cleanup(LPDIRECTDRAW7 iface)
{ {
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DX_WINDBG_trace();
if (ddgbl.lpDDCBtmp != NULL) if (ddgbl.lpDDCBtmp != NULL)
{ {
DxHeapMemFree(ddgbl.lpDDCBtmp); DxHeapMemFree(ddgbl.lpDDCBtmp);
@ -34,7 +36,7 @@ Cleanup(LPDIRECTDRAW7 iface)
*/ */
/* release the linked interface */ /* release the linked interface */
while (This->lpVtbl != NULL) while (!IsBadWritePtr( This->lpVtbl, sizeof( LPDDRAWI_DIRECTDRAW_INT )) )
{ {
LPDDRAWI_DIRECTDRAW_INT newThis = This->lpVtbl; LPDDRAWI_DIRECTDRAW_INT newThis = This->lpVtbl;
if (This->lpLcl != NULL) if (This->lpLcl != NULL)
@ -42,7 +44,8 @@ Cleanup(LPDIRECTDRAW7 iface)
DeleteDC(This->lpLcl->hDC); DeleteDC(This->lpLcl->hDC);
DxHeapMemFree(This->lpLcl); DxHeapMemFree(This->lpLcl);
} }
DxHeapMemFree(This);
This = newThis; This = newThis;
} }
@ -52,6 +55,10 @@ Cleanup(LPDIRECTDRAW7 iface)
DeleteDC(This->lpLcl->hDC); DeleteDC(This->lpLcl->hDC);
DxHeapMemFree(This->lpLcl); DxHeapMemFree(This->lpLcl);
} }
if (This != NULL)
{
DxHeapMemFree(This);
}
} }

View file

@ -85,7 +85,7 @@ Main_DirectDraw_Release (LPDIRECTDRAW7 iface)
This->lpLcl->lpGbl->dwRefCnt--; This->lpLcl->lpGbl->dwRefCnt--;
} }
if ( This->dwIntRefCnt == 0) if ( This->lpLcl->lpGbl->dwRefCnt == 0)
{ {
// set resoltion back to the one in registry // set resoltion back to the one in registry
/*if(This->cooperative_level & DDSCL_EXCLUSIVE) /*if(This->cooperative_level & DDSCL_EXCLUSIVE)
@ -94,13 +94,10 @@ Main_DirectDraw_Release (LPDIRECTDRAW7 iface)
}*/ }*/
Cleanup(iface); Cleanup(iface);
if (This!=NULL) return 0;
{
HeapFree(GetProcessHeap(), 0, This);
}
} }
} }
return This ? This->dwIntRefCnt : 0; return This->dwIntRefCnt;
} }
/* /*