Ken Thomases : winemac: Fix conversion of empty RECT to an empty CGRect.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jan 20 15:20:10 CST 2015


Module: wine
Branch: master
Commit: 50cd5b6a578a1427a501ef082017aebb66f132e1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=50cd5b6a578a1427a501ef082017aebb66f132e1

Author: Ken Thomases <ken at codeweavers.com>
Date:   Mon Jan 19 13:11:15 2015 -0600

winemac: Fix conversion of empty RECT to an empty CGRect.

For some empty RECTs, such as { INT_MAX, INT_MAX, INT_MIN, INT_MIN }, right
minus left or bottom minus top underflow and wrap around to positive values.

---

 dlls/winemac.drv/macdrv.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h
index 56ca24f..cf0fc64 100644
--- a/dlls/winemac.drv/macdrv.h
+++ b/dlls/winemac.drv/macdrv.h
@@ -47,7 +47,9 @@ extern const char* debugstr_cf(CFTypeRef t) DECLSPEC_HIDDEN;
 
 static inline CGRect cgrect_from_rect(RECT rect)
 {
-    return CGRectMake(rect.left, rect.top, max(0, rect.right - rect.left), max(0, rect.bottom - rect.top));
+    if (rect.left >= rect.right || rect.top >= rect.bottom)
+        return CGRectMake(rect.left, rect.top, 0, 0);
+    return CGRectMake(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
 }
 
 static inline RECT rect_from_cgrect(CGRect cgrect)




More information about the wine-cvs mailing list