Author: dchapyshev
Date: Sat Jul 30 11:31:33 2016
New Revision: 72052
URL:
http://svn.reactos.org/svn/reactos?rev=72052&view=rev
Log:
[USER32]
- Add missing NULL-pointer checkes in rect functions
- Small coding-style fixes
Modified:
trunk/reactos/win32ss/user/user32/windows/rect.c
Modified: trunk/reactos/win32ss/user/user32/windows/rect.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
==============================================================================
--- trunk/reactos/win32ss/user/user32/windows/rect.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/windows/rect.c [iso-8859-1] Sat Jul 30 11:31:33
2016
@@ -41,11 +41,12 @@
CopyRect(LPRECT lprcDst,
CONST RECT *lprcSrc)
{
- if(lprcDst == NULL || lprcSrc == NULL)
- return(FALSE);
+ if (lprcDst == NULL || lprcSrc == NULL)
+ return FALSE;
*lprcDst = *lprcSrc;
- return(TRUE);
+
+ return TRUE;
}
@@ -74,11 +75,15 @@
int dx,
int dy)
{
+ if (rect == NULL)
+ return FALSE;
+
rect->left -= dx;
rect->top -= dy;
rect->right += dx;
rect->bottom += dy;
- return(TRUE);
+
+ return TRUE;
}
@@ -91,6 +96,9 @@
CONST RECT *lprcSrc1,
CONST RECT *lprcSrc2)
{
+ if (lprcDst == NULL || lprcSrc1 == NULL || lprcSrc2 == NULL)
+ return FALSE;
+
if (IsRectEmpty(lprcSrc1) || IsRectEmpty(lprcSrc2) ||
lprcSrc1->left >= lprcSrc2->right ||
lprcSrc2->left >= lprcSrc1->right ||
@@ -98,13 +106,15 @@
lprcSrc2->top >= lprcSrc1->bottom)
{
SetRectEmpty(lprcDst);
- return(FALSE);
- }
+ return FALSE;
+ }
+
lprcDst->left = max(lprcSrc1->left, lprcSrc2->left);
lprcDst->right = min(lprcSrc1->right, lprcSrc2->right);
lprcDst->top = max(lprcSrc1->top, lprcSrc2->top);
lprcDst->bottom = min(lprcSrc1->bottom, lprcSrc2->bottom);
- return(TRUE);
+
+ return TRUE;
}
@@ -115,7 +125,10 @@
WINAPI
IsRectEmpty(CONST RECT *lprc)
{
- return((lprc->left >= lprc->right) || (lprc->top >=
lprc->bottom));
+ if (lprc == NULL)
+ return TRUE;
+
+ return ((lprc->left >= lprc->right) || (lprc->top >=
lprc->bottom));
}
@@ -128,14 +141,15 @@
int dx,
int dy)
{
- if(rect == NULL)
- return(FALSE);
+ if (rect == NULL)
+ return FALSE;
rect->left += dx;
rect->top += dy;
rect->right += dx;
rect->bottom += dy;
- return(TRUE);
+
+ return TRUE;
}
@@ -147,6 +161,9 @@
PtInRect(CONST RECT *lprc,
POINT pt)
{
+ if (lprc == NULL)
+ return FALSE;
+
return((pt.x >= lprc->left) && (pt.x < lprc->right) &&
(pt.y >= lprc->top) && (pt.y < lprc->bottom));
}
@@ -159,7 +176,7 @@
int xRight,
int yBottom)
{
- if (!lprc)
+ if (lprc == NULL)
return FALSE;
lprc->left = xLeft;
@@ -178,8 +195,12 @@
WINAPI
SetRectEmpty(LPRECT lprc)
{
+ if (lprc == NULL)
+ return FALSE;
+
lprc->left = lprc->right = lprc->top = lprc->bottom = 0;
- return(TRUE);
+
+ return TRUE;
}
@@ -194,13 +215,13 @@
{
RECT tempRect;
- if(lprcDst == NULL || lprcSrc1 == NULL || lprcSrc2 == NULL)
- return(FALSE);
-
- if(!IntersectRect(&tempRect, lprcSrc1, lprcSrc2))
+ if (lprcDst == NULL || lprcSrc1 == NULL || lprcSrc2 == NULL)
+ return FALSE;
+
+ if (!IntersectRect(&tempRect, lprcSrc1, lprcSrc2))
{
*lprcDst = *lprcSrc1;
- return(TRUE);
+ return TRUE;
}
if (EqualRect(&tempRect, lprcSrc1))
@@ -211,22 +232,22 @@
*lprcDst = *lprcSrc1;
- if(lprcDst->top == tempRect.top && lprcDst->bottom == tempRect.bottom)
- {
- if(lprcDst->left == tempRect.left)
+ if (lprcDst->top == tempRect.top && lprcDst->bottom ==
tempRect.bottom)
+ {
+ if (lprcDst->left == tempRect.left)
lprcDst->left = tempRect.right;
- else if(lprcDst->right == tempRect.right)
+ else if (lprcDst->right == tempRect.right)
lprcDst->right = tempRect.left;
}
- else if(lprcDst->left == tempRect.left && lprcDst->right ==
tempRect.right)
- {
- if(lprcDst->top == tempRect.top)
+ else if (lprcDst->left == tempRect.left && lprcDst->right ==
tempRect.right)
+ {
+ if (lprcDst->top == tempRect.top)
lprcDst->top = tempRect.bottom;
- else if(lprcDst->bottom == tempRect.bottom)
+ else if (lprcDst->bottom == tempRect.bottom)
lprcDst->bottom = tempRect.top;
}
- return(TRUE);
+ return TRUE;
}
@@ -239,12 +260,15 @@
CONST RECT *lprcSrc1,
CONST RECT *lprcSrc2)
{
+ if (lprcDst == NULL || lprcSrc1 == NULL || lprcSrc2 == NULL)
+ return FALSE;
+
if (IsRectEmpty(lprcSrc1))
{
if (IsRectEmpty(lprcSrc2))
{
SetRectEmpty(lprcDst);
- return(FALSE);
+ return FALSE;
}
else
{
@@ -266,5 +290,5 @@
}
}
- return(TRUE);
-}
+ return TRUE;
+}