Add NULL handling in SDL_RectEmpty and SDL_RectEquals
authorAndreas Schiffler <aschiffler@ferzkopp.net>
Fri, 16 Sep 2011 08:25:49 -0700
changeset 5947 2abc5a4210d5
parent 5942 00b695dde4bf
child 5948 05e6bfac079f
Add NULL handling in SDL_RectEmpty and SDL_RectEquals
include/SDL_rect.h
--- a/include/SDL_rect.h	Thu Sep 15 23:55:36 2011 -0400
+++ b/include/SDL_rect.h	Fri Sep 16 08:25:49 2011 -0700
@@ -71,12 +71,13 @@
 /**
  *  \brief Returns true if the rectangle has no area.
  */
-#define SDL_RectEmpty(X)    (((X)->w <= 0) || ((X)->h <= 0))
+#define SDL_RectEmpty(X)    ((!(X)) || ((X)->w <= 0) || ((X)->h <= 0))
 
 /**
  *  \brief Returns true if the two rectangles are equal.
  */
-#define SDL_RectEquals(A, B)   (((A)->x == (B)->x) && ((A)->y == (B)->y) && \
+#define SDL_RectEquals(A, B)   (((A) && ((B)) && \
+                                ((A)->x == (B)->x) && ((A)->y == (B)->y) && \
                                 ((A)->w == (B)->w) && ((A)->h == (B)->h))
 
 /**