DXGL r96 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r95‎ | r96 | r97 >
Date:20:40, 4 February 2012
Author:admin
Status:new
Tags:
Comment:
check a few more pointers
Modified paths:
  • /ddraw/glClassFactory.cpp (modified) (history)
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DLight.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glDirectDrawPalette.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/glClassFactory.cpp
@@ -41,6 +41,7 @@
4242 HRESULT WINAPI glClassFactory::QueryInterface(REFIID riid, void** ppvObj)
4343 {
4444 if(!this) return DDERR_INVALIDPARAMS;
 45+ if(!ppvObj) return DDERR_INVALIDPARAMS;
4546 if((riid == IID_IUnknown) || (riid == IID_IClassFactory))
4647 {
4748 *ppvObj = this;
Index: ddraw/glDirect3D.cpp
@@ -52,6 +52,7 @@
5353 HRESULT WINAPI glDirect3D7::QueryInterface(REFIID riid, void** ppvObj)
5454 {
5555 if(!this) return DDERR_INVALIDPARAMS;
 56+ if(!ppvObj) return DDERR_INVALIDPARAMS;
5657 FIXME("glDirect3D7::QueryInterface: stub");
5758 return E_NOINTERFACE;
5859 }
Index: ddraw/glDirect3DDevice.cpp
@@ -180,6 +180,7 @@
181181 HRESULT WINAPI glDirect3DDevice7::QueryInterface(REFIID riid, void** ppvObj)
182182 {
183183 if(!this) return DDERR_INVALIDPARAMS;
 184+ if(!ppvObj) return DDERR_INVALIDPARAMS;
184185 ERR(E_NOINTERFACE);
185186 }
186187
Index: ddraw/glDirect3DLight.cpp
@@ -69,6 +69,7 @@
7070 HRESULT WINAPI glDirect3DLight::QueryInterface(REFIID riid, void** ppvObj)
7171 {
7272 if(!this) return DDERR_INVALIDPARAMS;
 73+ if(!ppvObj) return DDERR_INVALIDPARAMS;
7374 return E_NOINTERFACE;
7475 }
7576
Index: ddraw/glDirectDraw.cpp
@@ -324,6 +324,7 @@
325325
326326 HRESULT EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback)
327327 {
 328+ if(!lpEnumModesCallback) return DDERR_INVALIDPARAMS;
328329 bool match;
329330 DWORD modenum = 0;
330331 DWORD modemax = 128;
@@ -597,6 +598,7 @@
598599 HRESULT WINAPI glDirectDraw7::QueryInterface(REFIID riid, void** ppvObj)
599600 {
600601 if(!this) return DDERR_INVALIDPARAMS;
 602+ if(!ppvObj) return DDERR_INVALIDPARAMS;
601603 if(riid == IID_IDirectDraw)
602604 {
603605 // Create an IDirectDraw1 interface
@@ -788,7 +790,8 @@
789791 ZeroMemory(&ddCaps,sizeof(DDCAPS_DX7));
790792 if(lpDDDriverCaps) ddCaps.dwSize = lpDDDriverCaps->dwSize;
791793 else if(lpDDHELCaps) ddCaps.dwSize = lpDDHELCaps->dwSize;
792 - else ERR(DDERR_INVALIDPARAMS);
 794+ if(ddCaps.dwSize > sizeof(DDCAPS_DX7)) ddCaps.dwSize = sizeof(DDCAPS_DX7);
 795+ else return DDERR_INVALIDPARAMS;
793796 ddCaps.dwCaps = DDCAPS_BLT | DDCAPS_BLTCOLORFILL | DDCAPS_BLTSTRETCH |
794797 DDCAPS_COLORKEY | DDCAPS_GDI | DDCAPS_PALETTE | DDCAPS_CANBLTSYSMEM;
795798 ddCaps.dwCaps2 = DDCAPS2_CANRENDERWINDOWED | DDCAPS2_WIDESURFACES | DDCAPS2_NOPAGELOCKREQUIRED |
@@ -801,14 +804,22 @@
802805 DDSCAPS_FRONTBUFFER | DDSCAPS_OFFSCREENPLAIN | DDSCAPS_PALETTE |
803806 DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY;
804807 ddCaps.dwCKeyCaps = DDCKEYCAPS_SRCBLT;
805 - if(lpDDDriverCaps) memcpy(lpDDDriverCaps,&ddCaps,lpDDDriverCaps->dwSize);
806 - if(lpDDHELCaps) memcpy(lpDDHELCaps,&ddCaps,lpDDHELCaps->dwSize);
 808+ if(lpDDDriverCaps)
 809+ {
 810+ if(lpDDDriverCaps->dwSize > sizeof(DDCAPS_DX7)) lpDDDriverCaps->dwSize = sizeof(DDCAPS_DX7);
 811+ memcpy(lpDDDriverCaps,&ddCaps,lpDDDriverCaps->dwSize);
 812+ }
 813+ if(lpDDHELCaps)
 814+ {
 815+ if(lpDDHELCaps->dwSize > sizeof(DDCAPS_DX7)) lpDDHELCaps->dwSize = sizeof(DDCAPS_DX7);
 816+ memcpy(lpDDHELCaps,&ddCaps,lpDDHELCaps->dwSize);
 817+ }
807818 return DD_OK;
808819 }
809820 HRESULT WINAPI glDirectDraw7::GetDisplayMode(LPDDSURFACEDESC2 lpDDSurfaceDesc2)
810821 {
811822 if(!this) return DDERR_INVALIDPARAMS;
812 - if(!lpDDSurfaceDesc2) ERR(DDERR_INVALIDPARAMS);
 823+ if(!lpDDSurfaceDesc2) return DDERR_INVALIDPARAMS;
813824 DDSURFACEDESC2 ddsdMode;
814825 ZeroMemory(&ddsdMode, sizeof(DDSURFACEDESC2));
815826 ddsdMode.dwSize = sizeof(DDSURFACEDESC2);
@@ -894,6 +905,8 @@
895906 HRESULT WINAPI glDirectDraw7::GetFourCCCodes(LPDWORD lpNumCodes, LPDWORD lpCodes)
896907 {
897908 if(!this) return DDERR_INVALIDPARAMS;
 909+ if(!lpNumCodes) return DDERR_INVALIDPARAMS;
 910+ if(!lpCodes) return DDERR_INVALIDPARAMS;
898911 FIXME("IDirectDraw::GetFourCCCodes: stub\n");
899912 ERR(DDERR_GENERIC);
900913 }
@@ -906,6 +919,7 @@
907920 HRESULT WINAPI glDirectDraw7::GetMonitorFrequency(LPDWORD lpdwFrequency)
908921 {
909922 if(!this) return DDERR_INVALIDPARAMS;
 923+ if(!lpdwFrequency) return DDERR_INVALIDPARAMS;
910924 DEBUG("IDirectDraw::GetMonitorFrequency: support multi-monitor\n");
911925 DEVMODE devmode;
912926 devmode.dmSize = sizeof(DEVMODE);
Index: ddraw/glDirectDrawClipper.cpp
@@ -36,6 +36,7 @@
3737 HRESULT WINAPI glDirectDrawClipper::QueryInterface(REFIID riid, LPVOID* obp)
3838 {
3939 if(!this) return DDERR_INVALIDPARAMS;
 40+ if(!obp) return DDERR_INVALIDPARAMS;
4041 if(riid == IID_IDirectDrawClipper)
4142 {
4243 *obp = this;
Index: ddraw/glDirectDrawPalette.cpp
@@ -116,6 +116,7 @@
117117 HRESULT WINAPI glDirectDrawPalette::QueryInterface(REFIID riid, void** ppvObj)
118118 {
119119 if(!this) return DDERR_INVALIDPARAMS;
 120+ if(!ppvObj) return DDERR_INVALIDPARAMS;
120121 ERR(E_NOINTERFACE);
121122 }
122123
Index: ddraw/glDirectDrawSurface.cpp
@@ -448,6 +448,7 @@
449449 HRESULT WINAPI glDirectDrawSurface7::QueryInterface(REFIID riid, void** ppvObj)
450450 {
451451 if(!this) return DDERR_INVALIDPARAMS;
 452+ if(!ppvObj) return DDERR_INVALIDPARAMS;
452453 if(riid == IID_IDirectDrawSurface7)
453454 {
454455 this->AddRef();
@@ -1101,8 +1102,7 @@
11021103 {
11031104 if(!this) return DDERR_INVALIDPARAMS;
11041105 *lplpDD = ddInterface;
1105 - FIXME("glDirectDrawSurface7::GetDDInterface: stub\n");
1106 - ERR(DDERR_GENERIC);
 1106+ return DD_OK;
11071107 }
11081108 HRESULT WINAPI glDirectDrawSurface7::PageLock(DWORD dwFlags)
11091109 {