Skip to content

Commit

Permalink
[X11] The inline cast of int32 EGLint to unsigned long XVisualInfo.vi…
Browse files Browse the repository at this point in the history
…sualid could cause the latter to be filled with a garbage value, resulting in no VisualInfo being returned later on.

Also add a check to make sure that visualinfo is not NULL.
  • Loading branch information
fosero committed Feb 28, 2015
1 parent 67fc238 commit ea8234e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions xbmc/windowing/X11/WinSystemX11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,17 +1102,27 @@ bool CWinSystemX11::SetWindow(int width, int height, bool fullscreen, const std:
CLog::Log(LOGERROR, "Failed to choose a config %d\n", eglGetError());
}

XVisualInfo x11_visual_info_template;
if (!eglGetConfigAttrib(m_eglDisplay, eglConfig, EGL_NATIVE_VISUAL_ID, (EGLint*)&x11_visual_info_template.visualid)) {
EGLint eglVisualid;
if (!eglGetConfigAttrib(m_eglDisplay, eglConfig, EGL_NATIVE_VISUAL_ID, &eglVisualid))
{
CLog::Log(LOGERROR, "Failed to query native visual id\n");
}
XVisualInfo x11_visual_info_template;
x11_visual_info_template.visualid = eglVisualid;
int num_visuals;
vi = XGetVisualInfo(m_dpy,
VisualIDMask,
&x11_visual_info_template,
&num_visuals);
&x11_visual_info_template,
&num_visuals);

#endif

if(!vi)
{
CLog::Log(LOGERROR, "Failed to find matching visual");
return false;
}

cmap = XCreateColormap(m_dpy, RootWindow(m_dpy, vi->screen), vi->visual, AllocNone);

bool hasWM = HasWindowManager();
Expand Down

0 comments on commit ea8234e

Please sign in to comment.