summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Isorce <j.isorce@samsung.com>2015-05-19 08:35:10 +0100
committerBrian Paul <brianp@vmware.com>2015-05-25 09:02:32 -0600
commitfca824431608101298ff0735db4c09954dcf64ab (patch)
treef989e0df3fe9bfe34c055c14a2d34fe062a3b07d
parent40d4d3b3c6c41f240de994c09e02fae357b42848 (diff)
downloadmesa-demos-fca824431608101298ff0735db4c09954dcf64ab.zip
mesa-demos-fca824431608101298ff0735db4c09954dcf64ab.tar.xz
glxinfo: fix segfault when core profile is unavailable
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85199 Signed-off-by: Julien Isorce <j.isorce@samsung.com> Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--src/xdemos/glinfo_common.c6
-rw-r--r--src/xdemos/glxinfo.c22
2 files changed, 16 insertions, 12 deletions
diff --git a/src/xdemos/glinfo_common.c b/src/xdemos/glinfo_common.c
index 6a360a3..5d865f3 100644
--- a/src/xdemos/glinfo_common.c
+++ b/src/xdemos/glinfo_common.c
@@ -289,9 +289,13 @@ build_core_profile_extension_list(const struct ext_functions *extfuncs)
totalLen = 0;
for (i = 0; i < n; i++) {
const char *ext = (const char *) extfuncs->GetStringi(GL_EXTENSIONS, i);
- totalLen += strlen(ext) + 1; /* plus a space */
+ if (ext)
+ totalLen += strlen(ext) + 1; /* plus a space */
}
+ if (!totalLen)
+ return NULL;
+
buffer = malloc(totalLen + 1);
if (buffer) {
int pos = 0;
diff --git a/src/xdemos/glxinfo.c b/src/xdemos/glxinfo.c
index 0f28647..dc29bd9 100644
--- a/src/xdemos/glxinfo.c
+++ b/src/xdemos/glxinfo.c
@@ -468,9 +468,9 @@ print_screen_info(Display *dpy, int scrnum,
const char *glVendor = (const char *) glGetString(GL_VENDOR);
const char *glRenderer = (const char *) glGetString(GL_RENDERER);
const char *glVersion = (const char *) glGetString(GL_VERSION);
- char *glExtensions;
- int glxVersionMajor;
- int glxVersionMinor;
+ char *glExtensions = NULL;
+ int glxVersionMajor = 0;
+ int glxVersionMinor = 0;
char *displayName = NULL;
char *colon = NULL, *period = NULL;
struct ext_functions extfuncs;
@@ -485,21 +485,21 @@ print_screen_info(Display *dpy, int scrnum,
extfuncs.GetConvolutionParameteriv = (GETCONVOLUTIONPARAMETERIVPROC)
glXGetProcAddressARB((GLubyte *) "glGetConvolutionParameteriv");
+ if (!glXQueryVersion(dpy, & glxVersionMajor, & glxVersionMinor)) {
+ fprintf(stderr, "Error: glXQueryVersion failed\n");
+ exit(1);
+ }
+
/* Get list of GL extensions */
- if (coreProfile) {
+ if (coreProfile && extfuncs.GetStringi && glxVersionMajor >= 3)
glExtensions = build_core_profile_extension_list(&extfuncs);
- }
- else {
+ if (!glExtensions) {
+ coreProfile = False;
glExtensions = (char *) glGetString(GL_EXTENSIONS);
}
CheckError(__LINE__);
- if (! glXQueryVersion( dpy, & glxVersionMajor, & glxVersionMinor )) {
- fprintf(stderr, "Error: glXQueryVersion failed\n");
- exit(1);
- }
-
if (!coreWorked) {
/* Strip the screen number from the display name, if present. */
if (!(displayName = (char *) malloc(strlen(DisplayString(dpy)) + 1))) {