[ros-diffs] [gvg] 20010: Never allocate 0 bytes. Fixes bug 1082.

gvg at svn.reactos.com gvg at svn.reactos.com
Fri Dec 9 18:56:30 CET 2005


Never allocate 0 bytes. Fixes bug 1082.
Modified: trunk/reactos/subsys/win32k/objects/region.c
  _____  

Modified: trunk/reactos/subsys/win32k/objects/region.c
--- trunk/reactos/subsys/win32k/objects/region.c	2005-12-09
17:11:20 UTC (rev 20009)
+++ trunk/reactos/subsys/win32k/objects/region.c	2005-12-09
17:56:26 UTC (rev 20010)
@@ -405,7 +405,11 @@

 static __inline int xmemcheck(ROSRGNDATA *reg, PRECT *rect, PRECT
*firstrect ) {
 	if ( (reg->rdh.nCount+1)*sizeof( RECT ) >= reg->rdh.nRgnSize ) {
 		PRECT temp;
-		temp = ExAllocatePoolWithTag( PagedPool, (2 *
(reg->rdh.nRgnSize)), TAG_REGION);
+		DWORD NewSize = 2 * reg->rdh.nRgnSize;
+		if (NewSize < (reg->rdh.nCount + 1) * sizeof(RECT)) {
+			NewSize = (reg->rdh.nCount + 1) * sizeof(RECT);
+		}
+		temp = ExAllocatePoolWithTag( PagedPool, NewSize,
TAG_REGION);
 
 		if (temp == 0)
 		    return 0;
@@ -413,7 +417,7 @@
                 /* copy the rectangles */
                 COPY_RECTS(temp, *firstrect, reg->rdh.nCount);
 
-		reg->rdh.nRgnSize *= 2;
+		reg->rdh.nRgnSize = NewSize;
 		if (*firstrect != &reg->rdh.rcBound)
 		    ExFreePool( *firstrect );
 		*firstrect = temp;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20051209/4542f5ce/attachment.html


More information about the Ros-diffs mailing list