From: Carl Worth <cworth@cworth.org>
Date: Mon, 23 Sep 2013 14:00:51 +0000 (-0700)
Subject: Fix segmentation fault if GLAZE_LIBGL is set to empty string
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=ac96e5c9b7b834687eebc503580937934b9abc57;p=glaze

Fix segmentation fault if GLAZE_LIBGL is set to empty string

Previosuly, we would catch and report an unset GLAZE_LIBGL variable
with a clean error message so that the user would know to set this
variable. Similarly, if the variable was set to an incorrect filename,
that would also result in a good error message.

But, if the user happened to set GLAZE_LIBGL to an empty string, then
Glaze would march on and end up triggering the dlsym behavior where a
NULL handle results in a lookup in the local program. This would then
trigger infinite recursion in the resolving of the ifunc symbol and a
not-very-useful segfault.

We avoid all that by noticing the empty string up front and giving the
user the useful error message.
---

diff --git a/glaze-gl.c b/glaze-gl.c
index e7dd728..04f288e 100644
--- a/glaze-gl.c
+++ b/glaze-gl.c
@@ -51,7 +51,7 @@ open_libgl_handle (void)
 		libgl_path = getenv ("GLAZE_LIBGL_64_AUTO");
 #endif
 
-		if (libgl_path == NULL) {
+		if (libgl_path == NULL || strlen (libgl_path) == 0) {
 			fprintf (stderr,
 				 "Error: Failed to detect OpenGL library.\n"
 				 "Please set GLAZE_LIBGL to path of real libGL.so\n");