diff options
author | reveman@google.com <reveman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-23 21:47:55 +0000 |
---|---|---|
committer | reveman@google.com <reveman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-23 21:47:55 +0000 |
commit | 552e42c3adc10050c6572615655812ef9478659a (patch) | |
tree | c06064e9dac39a58a69b0b66c94cf8e319b2c3f9 | |
parent | 022e3f4f2d921d468f1a955c9e06808be64b7d5e (diff) | |
download | chromium_src-552e42c3adc10050c6572615655812ef9478659a.zip chromium_src-552e42c3adc10050c6572615655812ef9478659a.tar.gz chromium_src-552e42c3adc10050c6572615655812ef9478659a.tar.bz2 |
Merge 100772 - Check return value of XGetWindowAttributes.
There is a chance that window is no longer valid and the call to XGetWindowAttributes will fail and leave |attributes| uninitialized.
BUG=chromium-os:16986
TEST=manual
Review URL: http://codereview.chromium.org/7831063
TBR=reveman@google.com
Review URL: http://codereview.chromium.org/7951007
git-svn-id: svn://svn.chromium.org/chrome/branches/835/src@102586 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/base/x/x11_util.cc | 3 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_glx.cc | 8 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_glx.cc | 14 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_linux.cc | 13 |
4 files changed, 29 insertions, 9 deletions
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index d7d51cf..dbbaddb 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -205,7 +205,8 @@ int BitsPerPixelForPixmapDepth(Display* dpy, int depth) { bool IsWindowVisible(XID window) { XWindowAttributes win_attributes; - XGetWindowAttributes(GetXDisplay(), window, &win_attributes); + if (!XGetWindowAttributes(GetXDisplay(), window, &win_attributes)) + return false; if (win_attributes.map_state != IsViewable) return false; // Some compositing window managers (notably kwin) do not actually unmap diff --git a/ui/gfx/gl/gl_context_glx.cc b/ui/gfx/gl/gl_context_glx.cc index 0921037..f61d37f 100644 --- a/ui/gfx/gl/gl_context_glx.cc +++ b/ui/gfx/gl/gl_context_glx.cc @@ -104,10 +104,14 @@ bool GLContextGLX::Initialize(GLSurface* compatible_surface) { // Get the visuals for the X drawable. XWindowAttributes attributes; - XGetWindowAttributes( + if (!XGetWindowAttributes( display, reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()), - &attributes); + &attributes)) { + LOG(ERROR) << "XGetWindowAttributes failed for window " << + reinterpret_cast<GLXDrawable>(surface_glx->GetHandle()) << "."; + return false; + } XVisualInfo visual_info_template; visual_info_template.visualid = XVisualIDFromVisual(attributes.visual); diff --git a/ui/gfx/gl/gl_surface_glx.cc b/ui/gfx/gl/gl_surface_glx.cc index 30cf490..f26970e 100644 --- a/ui/gfx/gl/gl_surface_glx.cc +++ b/ui/gfx/gl/gl_surface_glx.cc @@ -131,7 +131,10 @@ bool NativeViewGLSurfaceGLX::SwapBuffers() { gfx::Size NativeViewGLSurfaceGLX::GetSize() { XWindowAttributes attributes; - XGetWindowAttributes(g_display, window_, &attributes); + if (!XGetWindowAttributes(g_display, window_, &attributes)) { + LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; + return gfx::Size(); + } return gfx::Size(attributes.width, attributes.height); } @@ -154,10 +157,15 @@ void* NativeViewGLSurfaceGLX::GetConfig() { // it. XWindowAttributes attributes; - XGetWindowAttributes( + if (!XGetWindowAttributes( g_display, reinterpret_cast<GLXDrawable>(GetHandle()), - &attributes); + &attributes)) { + LOG(ERROR) << "XGetWindowAttributes failed for window " << + reinterpret_cast<GLXDrawable>(GetHandle()) << "."; + return NULL; + } + int visual_id = XVisualIDFromVisual(attributes.visual); int num_elements = 0; diff --git a/ui/gfx/gl/gl_surface_linux.cc b/ui/gfx/gl/gl_surface_linux.cc index 968ca618..86cc2ec 100644 --- a/ui/gfx/gl/gl_surface_linux.cc +++ b/ui/gfx/gl/gl_surface_linux.cc @@ -173,9 +173,13 @@ bool NativeViewGLSurfaceOSMesa::SwapBuffers() { gfx::Size size = GetSize(); - // Copy the frame into the pixmap. XWindowAttributes attributes; - XGetWindowAttributes(g_osmesa_display, window_, &attributes); + if (!XGetWindowAttributes(g_osmesa_display, window_, &attributes)) { + LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; + return false; + } + + // Copy the frame into the pixmap. ui::PutARGBImage(g_osmesa_display, attributes.visual, attributes.depth, @@ -200,7 +204,10 @@ bool NativeViewGLSurfaceOSMesa::SwapBuffers() { bool NativeViewGLSurfaceOSMesa::UpdateSize() { // Get the window size. XWindowAttributes attributes; - XGetWindowAttributes(g_osmesa_display, window_, &attributes); + if (!XGetWindowAttributes(g_osmesa_display, window_, &attributes)) { + LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; + return false; + } gfx::Size window_size = gfx::Size(std::max(1, attributes.width), std::max(1, attributes.height)); |