From b3b8bd9af7bf1fcfe544fd131f4d4f0d117ae7bc Mon Sep 17 00:00:00 2001 From: Yaron Cohen-Tal Date: Tue, 29 Sep 2015 11:57:55 +0300 Subject: [PATCH] Fix "epoxy_glx_version" to handle the case when GLX is not active on the display. --- src/dispatch_glx.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/dispatch_glx.c b/src/dispatch_glx.c index f1ff447..36d513a 100644 --- a/src/dispatch_glx.c +++ b/src/dispatch_glx.c @@ -54,22 +54,23 @@ epoxy_glx_version(Display *dpy, int screen) int client_major, client_minor; int server, client; const char *version_string; - int ret; + int ret=0, sscanf_ret; - version_string = glXQueryServerString(dpy, screen, GLX_VERSION); - ret = sscanf(version_string, "%d.%d", &server_major, &server_minor); - assert(ret == 2); - server = server_major * 10 + server_minor; + if ((version_string = glXQueryServerString(dpy, screen, GLX_VERSION))) + { + sscanf_ret = sscanf(version_string, "%d.%d", &server_major, &server_minor); + assert(sscanf_ret == 2); + server = server_major * 10 + server_minor; + if ((version_string = glXGetClientString(dpy, GLX_VERSION))) + { + sscanf_ret = sscanf(version_string, "%d.%d", &client_major, &client_minor); + assert(sscanf_ret == 2); + client = client_major * 10 + client_minor; + ret = client <= server ? client : server; + } + } - version_string = glXGetClientString(dpy, GLX_VERSION); - ret = sscanf(version_string, "%d.%d", &client_major, &client_minor); - assert(ret == 2); - client = client_major * 10 + client_minor; - - if (client < server) - return client; - else - return server; + return ret; } /**