ecore-x: Add EINA_SAFETY checks for missing display
authorChris Michael <cpmichael@osg.samsung.com>
Fri, 12 Feb 2016 13:27:35 +0000 (08:27 -0500)
committerChris Michael <cpmichael@osg.samsung.com>
Fri, 12 Feb 2016 13:28:10 +0000 (08:28 -0500)
xlib immediately crashes upon being passed a null DISPLAY object,
so every function in ecore-x should likely have safety checks such
as these.

@fix

Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
src/lib/ecore_x/xlib/ecore_x_drawable.c

index 1742c5b..e0edbe2 100644 (file)
@@ -32,6 +32,7 @@ ecore_x_drawable_geometry_get(Ecore_X_Drawable d,
    unsigned int ret_w, ret_h, dummy_border, dummy_depth;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &ret_x, &ret_y,
                      &ret_w, &ret_h, &dummy_border, &dummy_depth))
      {
@@ -69,6 +70,7 @@ ecore_x_drawable_border_width_get(Ecore_X_Drawable d)
    unsigned int dummy_w, dummy_h, border_ret, dummy_depth;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
                      &dummy_w, &dummy_h, &border_ret, &dummy_depth))
      border_ret = 0;
@@ -90,6 +92,7 @@ ecore_x_drawable_depth_get(Ecore_X_Drawable d)
    unsigned int dummy_w, dummy_h, dummy_border, depth_ret;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
                      &dummy_w, &dummy_h, &dummy_border, &depth_ret))
      depth_ret = 0;
@@ -115,6 +118,7 @@ ecore_x_drawable_rectangle_fill(Ecore_X_Drawable d,
                                 int height)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
    XFillRectangle(_ecore_x_disp, d, gc, x, y, width, height);
    if (_ecore_xlib_sync) ecore_x_sync();
 }