forked from enlightenment/efl
ecore-x: Add EINA_SAFETY checks for missing display
xlib immediately crashes upon being passed a null DISPLAY object,
so every function in ecore-x should likely have safety checks such
as these.
@ref 210b3e6c62
@fix
Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
This commit is contained in:
parent
b4f254e1a3
commit
adeb28a1c0
|
@ -879,6 +879,7 @@ EAPI int
|
|||
ecore_x_fd_get(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
|
||||
return ConnectionNumber(_ecore_x_disp);
|
||||
}
|
||||
|
||||
|
@ -891,6 +892,7 @@ EAPI Ecore_X_Screen *
|
|||
ecore_x_default_screen_get(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, NULL);
|
||||
return (Ecore_X_Screen *)DefaultScreenOfDisplay(_ecore_x_disp);
|
||||
}
|
||||
|
||||
|
@ -930,7 +932,7 @@ EAPI int
|
|||
ecore_x_screen_count_get(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
|
||||
return ScreenCount(_ecore_x_disp);
|
||||
}
|
||||
|
||||
|
@ -961,6 +963,7 @@ ecore_x_screen_index_get(const Ecore_X_Screen *screen)
|
|||
EAPI Ecore_X_Screen *
|
||||
ecore_x_screen_get(int idx)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, NULL);
|
||||
return XScreenOfDisplay(_ecore_x_disp, idx);
|
||||
}
|
||||
|
||||
|
@ -1012,6 +1015,7 @@ EAPI void
|
|||
ecore_x_flush(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
XFlush(_ecore_x_disp);
|
||||
}
|
||||
|
||||
|
@ -1024,6 +1028,7 @@ EAPI void
|
|||
ecore_x_sync(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
XSync(_ecore_x_disp, False);
|
||||
}
|
||||
|
||||
|
@ -1046,6 +1051,7 @@ ecore_x_killall(Ecore_X_Window root)
|
|||
unsigned int num_children = 0;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
XGrabServer(_ecore_x_disp);
|
||||
/* Tranverse window tree starting from root, and drag each
|
||||
* before the firing squad */
|
||||
|
@ -1074,6 +1080,7 @@ EAPI void
|
|||
ecore_x_kill(Ecore_X_Window win)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
XKillClient(_ecore_x_disp, win);
|
||||
if (_ecore_xlib_sync) ecore_x_sync();
|
||||
}
|
||||
|
@ -1102,6 +1109,7 @@ ecore_x_dpi_get(void)
|
|||
Screen *s;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
s = DefaultScreenOfDisplay(_ecore_x_disp);
|
||||
if (s->mwidth <= 0)
|
||||
return 75;
|
||||
|
@ -1126,6 +1134,7 @@ ecore_x_bell(int percent)
|
|||
{
|
||||
int ret;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
ret = XBell(_ecore_x_disp, percent);
|
||||
if (ret == BadValue)
|
||||
return EINA_FALSE;
|
||||
|
@ -2069,6 +2078,7 @@ ecore_x_client_message32_send(Ecore_X_Window win,
|
|||
Eina_Bool ret;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
xev.xclient.window = win;
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.message_type = type;
|
||||
|
@ -2104,6 +2114,7 @@ ecore_x_client_message8_send(Ecore_X_Window win,
|
|||
Eina_Bool ret;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
xev.xclient.window = win;
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.message_type = type;
|
||||
|
@ -2132,6 +2143,7 @@ ecore_x_mouse_move_send(Ecore_X_Window win,
|
|||
Eina_Bool ret;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
XGetWindowAttributes(_ecore_x_disp, win, &att);
|
||||
XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
|
||||
xev.xmotion.type = MotionNotify;
|
||||
|
@ -2164,6 +2176,7 @@ ecore_x_mouse_down_send(Ecore_X_Window win,
|
|||
Eina_Bool ret;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
XGetWindowAttributes(_ecore_x_disp, win, &att);
|
||||
XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
|
||||
xev.xbutton.type = ButtonPress;
|
||||
|
@ -2196,6 +2209,7 @@ ecore_x_mouse_up_send(Ecore_X_Window win,
|
|||
Eina_Bool ret;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
XGetWindowAttributes(_ecore_x_disp, win, &att);
|
||||
XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
|
||||
xev.xbutton.type = ButtonRelease;
|
||||
|
@ -2227,6 +2241,7 @@ ecore_x_mouse_in_send(Ecore_X_Window win,
|
|||
Eina_Bool ret;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
XGetWindowAttributes(_ecore_x_disp, win, &att);
|
||||
XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
|
||||
xev.xcrossing.type = EnterNotify;
|
||||
|
@ -2260,6 +2275,7 @@ ecore_x_mouse_out_send(Ecore_X_Window win,
|
|||
Eina_Bool ret;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, EINA_FALSE);
|
||||
XGetWindowAttributes(_ecore_x_disp, win, &att);
|
||||
XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
|
||||
xev.xcrossing.type = LeaveNotify;
|
||||
|
@ -2285,6 +2301,7 @@ EAPI void
|
|||
ecore_x_focus_reset(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
XSetInputFocus(_ecore_x_disp, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
if (_ecore_xlib_sync) ecore_x_sync();
|
||||
}
|
||||
|
@ -2293,6 +2310,7 @@ EAPI void
|
|||
ecore_x_events_allow_all(void)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
XAllowEvents(_ecore_x_disp, AsyncBoth, CurrentTime);
|
||||
if (_ecore_xlib_sync) ecore_x_sync();
|
||||
}
|
||||
|
@ -2318,6 +2336,7 @@ ecore_x_pointer_xy_get(Ecore_X_Window win,
|
|||
unsigned int mask;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
ret = XQueryPointer(_ecore_x_disp, win, &rwin, &cwin,
|
||||
&rx, &ry, &wx, &wy, &mask);
|
||||
if (!ret)
|
||||
|
@ -2338,6 +2357,7 @@ ecore_x_pointer_root_xy_get(int *x, int *y)
|
|||
unsigned int mask;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
root = ecore_x_window_root_list(&num);
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
|
@ -2430,6 +2450,7 @@ EAPI void
|
|||
ecore_x_xkb_select_group(int group)
|
||||
{
|
||||
#ifdef ECORE_XKB
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
XkbLockGroup(_ecore_x_disp, XkbUseCoreKbd, group);
|
||||
if (_ecore_xlib_sync) ecore_x_sync();
|
||||
#endif
|
||||
|
@ -2473,4 +2494,3 @@ _ecore_x_event_modifier(unsigned int state)
|
|||
|
||||
return xmodifiers;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ ecore_x_atom_get(const char *name)
|
|||
return 0;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
atom = XInternAtom(_ecore_x_disp, name, False);
|
||||
if (_ecore_xlib_sync) ecore_x_sync();
|
||||
return atom;
|
||||
|
@ -62,10 +63,8 @@ ecore_x_atoms_get(const char **names,
|
|||
Atom *atoms_int;
|
||||
int i;
|
||||
|
||||
if (!_ecore_x_disp)
|
||||
return;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
atoms_int = alloca(num * sizeof(Atom));
|
||||
XInternAtoms(_ecore_x_disp, (char **)names, num, False, atoms_int);
|
||||
for (i = 0; i < num; i++)
|
||||
|
@ -79,11 +78,10 @@ ecore_x_atom_name_get(Ecore_X_Atom atom)
|
|||
char *name;
|
||||
char *xname;
|
||||
|
||||
if (!_ecore_x_disp)
|
||||
return NULL;
|
||||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, NULL);
|
||||
|
||||
xname = XGetAtomName(_ecore_x_disp, atom);
|
||||
if (_ecore_xlib_sync) ecore_x_sync();
|
||||
if (!xname)
|
||||
|
|
|
@ -22,6 +22,7 @@ ecore_x_cursor_new(Ecore_X_Window win,
|
|||
{
|
||||
#ifdef ECORE_XCURSOR
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (_ecore_x_xcursor)
|
||||
{
|
||||
Cursor c;
|
||||
|
@ -217,6 +218,7 @@ EAPI void
|
|||
ecore_x_cursor_free(Ecore_X_Cursor c)
|
||||
{
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
XFreeCursor(_ecore_x_disp, c);
|
||||
if (_ecore_xlib_sync) ecore_x_sync();
|
||||
}
|
||||
|
@ -242,6 +244,7 @@ ecore_x_cursor_size_set(int size)
|
|||
{
|
||||
#ifdef ECORE_XCURSOR
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
|
||||
XcursorSetDefaultSize(_ecore_x_disp, size);
|
||||
if (_ecore_xlib_sync) ecore_x_sync();
|
||||
#else /* ifdef ECORE_XCURSOR */
|
||||
|
@ -254,6 +257,7 @@ ecore_x_cursor_size_get(void)
|
|||
{
|
||||
#ifdef ECORE_XCURSOR
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(_ecore_x_disp, 0);
|
||||
return XcursorGetDefaultSize(_ecore_x_disp);
|
||||
#else /* ifdef ECORE_XCURSOR */
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue