[DDRAW] DD_STRUCT_COPY_BYSIZE: Do not clear more that struct size

Christian Costa titan.costa at wanadoo.fr
Mon Mar 15 13:08:32 CST 2004


Hi,

Apps should initialize correctly the dwSize member of ddraw structures.
However some of them do not do this and Windows seems to handle that 
case without crashing.
Here is a patch that prevents clearing more that the struct size.
This fixes the bug 2070.

Bye.

Changelog :
DD_STRUCT_COPY_BYSIZE: Do not clear more that struct size

Christian Costa   titan.costa at wanadoo.fr
-------------- next part --------------
Index: ddraw_private.h
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/ddraw_private.h,v
retrieving revision 1.40
diff -u -r1.40 ddraw_private.h
--- ddraw_private.h	15 Sep 2003 20:00:03 -0000	1.40
+++ ddraw_private.h	15 Mar 2004 17:49:02 -0000
@@ -45,7 +45,10 @@
 	do {						\
 	    	DWORD __size = (to)->dwSize;		\
 	    	DWORD __copysize = __size;		\
-                memset(to,0,__size);                    \
+	    	DWORD __resetsize = __size;		\
+	        if (__resetsize > sizeof(*to))		\
+		    __resetsize = sizeof(*to);		\
+	    	memset(to,0,__resetsize);               \
 	        if ((from)->dwSize < __size) 		\
 		    __copysize = (from)->dwSize;	\
 		memcpy(to,from,__copysize);		\


More information about the wine-patches mailing list