Never allocate 0 bytes. Fixes bug 1082.
authorGé van Geldorp <ge@gse.nl>
Fri, 9 Dec 2005 17:56:26 +0000 (17:56 +0000)
committerGé van Geldorp <ge@gse.nl>
Fri, 9 Dec 2005 17:56:26 +0000 (17:56 +0000)
svn path=/trunk/; revision=20010

reactos/subsys/win32k/objects/region.c

index ac85116..b976376 100644 (file)
@@ -405,7 +405,11 @@ typedef struct _ScanLineListBlock {
 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 @@ static __inline int xmemcheck(ROSRGNDATA *reg, PRECT *rect, PRECT *firstrect ) {
                 /* 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;