From 4a266dc920a21c2a3f16568dbc87f92e94fe0130 Mon Sep 17 00:00:00 2001 From: Shaolin Date: Fri, 3 Aug 2018 00:52:47 -0300 Subject: [PATCH 1/2] libobs-opengl: Improve X error handler message --- libobs-opengl/gl-x11.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libobs-opengl/gl-x11.c b/libobs-opengl/gl-x11.c index 2653cb150..4ea99d6aa 100644 --- a/libobs-opengl/gl-x11.c +++ b/libobs-opengl/gl-x11.c @@ -323,10 +323,16 @@ error: static int x_error_handler(Display *display, XErrorEvent *error) { - char str[512]; - XGetErrorText(display, error->error_code, str, sizeof(str)); + char str1[512]; + char str2[512]; + char str3[512]; + XGetErrorText(display, error->error_code, str1, sizeof(str1)); + XGetErrorText(display, error->request_code, str2, sizeof(str2)); + XGetErrorText(display, error->minor_code, str3, sizeof(str3)); - blog(LOG_ERROR, "X Error: %s", str); + blog(LOG_ERROR, "X Error: %s, Major opcode: %s, " + "Minor opcode: %s, Serial: %lu", + str1, str2, str3, error->serial); return 0; } From 85c7669ad22498199c3cfdb6bfc851935d6740f7 Mon Sep 17 00:00:00 2001 From: Shaolin Date: Fri, 3 Aug 2018 00:55:09 -0300 Subject: [PATCH 2/2] libobs-opengl: Fix segfault on access of invalid window Once a window is invalid gl-x11::get_window_geometry will return 0 so just check if the returned geometry is a valid pointer before trying to get its width/height. --- libobs-opengl/gl-x11.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libobs-opengl/gl-x11.c b/libobs-opengl/gl-x11.c index 4ea99d6aa..697ef3806 100644 --- a/libobs-opengl/gl-x11.c +++ b/libobs-opengl/gl-x11.c @@ -520,8 +520,10 @@ extern void gl_getclientsize(const struct gs_swap_chain *swap, xcb_window_t window = swap->wi->window; xcb_get_geometry_reply_t *geometry = get_window_geometry(xcb_conn, window); - *width = geometry->width; - *height = geometry->height; + if (geometry) { + *width = geometry->width; + *height = geometry->height; + } free(geometry); }