Stefan Dösinger : wined3d: Avoid a NULL pointer dereference in UpdateTexture (Coverity).
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jan 12 05:39:10 CST 2007
Module: wine
Branch: master
Commit: ce0773a02e90c2cfbc506976207c5fe28037f1b3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ce0773a02e90c2cfbc506976207c5fe28037f1b3
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Fri Jan 12 00:20:42 2007 +0100
wined3d: Avoid a NULL pointer dereference in UpdateTexture (Coverity).
---
dlls/wined3d/device.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 5f964fb..8a02e31 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5162,7 +5162,7 @@ static HRESULT WINAPI IWineD3DDeviceIm
unsigned int srcSurfaceWidth, srcSurfaceHeight, destSurfaceWidth, destSurfaceHeight;
WINED3DFORMAT destFormat, srcFormat;
UINT destSize;
- int destLeft, destTop;
+ int srcLeft, destLeft, destTop;
WINED3DPOOL srcPool, destPool;
int offset = 0;
int rowoffset = 0; /* how many bytes to add onto the end of a row to wraparound to the beginning of the next */
@@ -5212,15 +5212,16 @@ static HRESULT WINAPI IWineD3DDeviceIm
/* this needs to be done in lines if the sourceRect != the sourceWidth */
srcWidth = pSourceRect ? pSourceRect->right - pSourceRect->left : srcSurfaceWidth;
srcHeight = pSourceRect ? pSourceRect->top - pSourceRect->bottom : srcSurfaceHeight;
+ srcLeft = pSourceRect ? pSourceRect->left : 0;
destLeft = pDestPoint ? pDestPoint->x : 0;
destTop = pDestPoint ? pDestPoint->y : 0;
/* This function doesn't support compressed textures
the pitch is just bytesPerPixel * width */
- if(srcWidth != srcSurfaceWidth || (pSourceRect != NULL && pSourceRect->left != 0) ){
+ if(srcWidth != srcSurfaceWidth || srcLeft ){
rowoffset = (srcSurfaceWidth - srcWidth) * pSrcSurface->bytesPerPixel;
- offset += pSourceRect->left * pSrcSurface->bytesPerPixel;
+ offset += srcLeft * pSrcSurface->bytesPerPixel;
/* TODO: do we ever get 3bpp?, would a shift and an add be quicker than a mul (well maybe a cycle or two) */
}
/* TODO DXT formats */
More information about the wine-cvs
mailing list