DXGL r856 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r855‎ | r856 | r857 >
Date:00:20, 6 September 2018
Author:admin
Status:new
Tags:
Comment:
Set version to 0.5.16 pre-release
Fix access to non-initialized data when performing color fill Blt().
Implement IDirectDrawPalette::QueryInterface
Validate parameters in IDirectDrawPalette::GetEntries and SetEntries.
Modified paths:
  • /common/releasever.h (modified) (history)
  • /ddraw/glDirectDrawPalette.c (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: common/releasever.h
@@ -4,8 +4,8 @@
55
66 #define DXGLMAJORVER 0
77 #define DXGLMINORVER 5
8 -#define DXGLPOINTVER 15
9 -#define DXGLBETA 0
 8+#define DXGLPOINTVER 16
 9+#define DXGLBETA 1
1010
1111 #define STR2(x) #x
1212 #define STR(x) STR2(x)
Index: ddraw/glDirectDrawPalette.c
@@ -142,8 +142,16 @@
143143 TRACE_EXIT(23,DD_OK);
144144 return DD_OK;
145145 }
 146+ if (!memcmp(riid, &IID_IDirectDrawPalette, sizeof(GUID)))
 147+ {
 148+ glDirectDrawPalette_AddRef(This);
 149+ *ppvObj = This;
 150+ TRACE_VAR("*ppvObj", 14, *ppvObj);
 151+ TRACE_EXIT(23, DD_OK);
 152+ return DD_OK;
 153+ }
146154 TRACE_EXIT(23,E_NOINTERFACE);
147 - ERR(E_NOINTERFACE);
 155+ return E_NOINTERFACE;
148156 }
149157
150158 ULONG WINAPI glDirectDrawPalette_AddRef(glDirectDrawPalette *This)
@@ -187,7 +195,9 @@
188196 DWORD allentries = 256;
189197 DWORD entrysize;
190198 TRACE_ENTER(5, 14, This, 9, dwFlags, 8, dwBase, 8, dwNumEntries, 14, lpEntries);
 199+ if (dwFlags) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
191200 if (!IsReadablePointer(This, sizeof(glDirectDrawPalette))) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 201+ if (!IsWritablePointer(lpEntries, dwNumEntries * 4, FALSE)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
192202 if(This->flags & DDPCAPS_1BIT) allentries=2;
193203 if(This->flags & DDPCAPS_2BIT) allentries=4;
194204 if(This->flags & DDPCAPS_4BIT) allentries=16;
@@ -212,7 +222,9 @@
213223 DWORD entrysize;
214224 DDSURFACEDESC2 ddsd;
215225 TRACE_ENTER(5, 14, This, 9, dwFlags, 8, dwStartingEntry, 8, dwCount, 14, lpEntries);
 226+ if (dwFlags) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
216227 if (!IsReadablePointer(This, sizeof(glDirectDrawPalette))) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
 228+ if (!IsReadablePointer(lpEntries, dwCount * 4)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
217229 if(This->flags & DDPCAPS_1BIT) allentries=2;
218230 if(This->flags & DDPCAPS_2BIT) allentries=4;
219231 if(This->flags & DDPCAPS_4BIT) allentries=16;
Index: ddraw/glRenderer.cpp
@@ -3412,25 +3412,33 @@
34133413 {
34143414 ddsdSrc = cmd->src->levels[cmd->srclevel].ddsd;
34153415 if (cmd->src->levels[cmd->srclevel].dirty & 1) glTexture__Upload(cmd->src, cmd->srclevel);
 3416+ if (!memcmp(&cmd->srcrect, &nullrect, sizeof(RECT)))
 3417+ {
 3418+ srcrect.left = 0;
 3419+ srcrect.top = 0;
 3420+ srcrect.right = ddsdSrc.dwWidth;
 3421+ srcrect.bottom = ddsdSrc.dwHeight;
 3422+ }
34163423 }
34173424 if (cmd->dest->levels[cmd->destlevel].dirty & 1)
34183425 glTexture__Upload(cmd->dest, cmd->destlevel);
3419 - if (!memcmp(&cmd->srcrect, &nullrect, sizeof(RECT)))
3420 - {
3421 - srcrect.left = 0;
3422 - srcrect.top = 0;
3423 - srcrect.right = ddsdSrc.dwWidth;
3424 - srcrect.bottom = ddsdSrc.dwHeight;
3425 - }
34263426 else srcrect = cmd->srcrect;
34273427 This->bltvertices[1].x = This->bltvertices[3].x = (GLfloat)destrect.left;
34283428 This->bltvertices[0].x = This->bltvertices[2].x = (GLfloat)destrect.right;
34293429 This->bltvertices[0].y = This->bltvertices[1].y = (GLfloat)ddsd.dwHeight - (GLfloat)destrect.top;
34303430 This->bltvertices[2].y = This->bltvertices[3].y = (GLfloat)ddsd.dwHeight - (GLfloat)destrect.bottom;
3431 - This->bltvertices[1].s = This->bltvertices[3].s = (GLfloat)srcrect.left / (GLfloat)ddsdSrc.dwWidth;
3432 - This->bltvertices[0].s = This->bltvertices[2].s = (GLfloat)srcrect.right / (GLfloat)ddsdSrc.dwWidth;
3433 - This->bltvertices[0].t = This->bltvertices[1].t = (GLfloat)srcrect.top / (GLfloat)ddsdSrc.dwHeight;
3434 - This->bltvertices[2].t = This->bltvertices[3].t = (GLfloat)srcrect.bottom / (GLfloat)ddsdSrc.dwHeight;
 3431+ if (cmd->src)
 3432+ {
 3433+ This->bltvertices[1].s = This->bltvertices[3].s = (GLfloat)srcrect.left / (GLfloat)ddsdSrc.dwWidth;
 3434+ This->bltvertices[0].s = This->bltvertices[2].s = (GLfloat)srcrect.right / (GLfloat)ddsdSrc.dwWidth;
 3435+ This->bltvertices[0].t = This->bltvertices[1].t = (GLfloat)srcrect.top / (GLfloat)ddsdSrc.dwHeight;
 3436+ This->bltvertices[2].t = This->bltvertices[3].t = (GLfloat)srcrect.bottom / (GLfloat)ddsdSrc.dwHeight;
 3437+ }
 3438+ else
 3439+ {
 3440+ This->bltvertices[1].s = This->bltvertices[3].s = This->bltvertices[0].t = This->bltvertices[1].t = 0.0f;
 3441+ This->bltvertices[0].s = This->bltvertices[2].s = This->bltvertices[2].t = This->bltvertices[3].t = 1.0f;
 3442+ }
34353443 if ((cmd->bltfx.dwSize == sizeof(DDBLTFX)) && (cmd->flags & DDBLT_DDFX))
34363444 {
34373445 if (cmd->bltfx.dwDDFX & DDBLTFX_MIRRORLEFTRIGHT)

Follow-up revisions

RevisionCommit summaryAuthorDate
r861Revert r856 of glRenderer.cppadmin14:44, 9 September 2018