From f94f9bc3358d29b8cf7c03d753808bbbb61a5a3f Mon Sep 17 00:00:00 2001 From: Ian Elliott Date: Fri, 20 Feb 2015 14:12:18 -0700 Subject: [PATCH] xcb: Deal with case of getenv() returning NULL. At least on Windows, getenv() returns NULL when the environment variable is not found. This causes a problem inside of "xcb_nvidia.cpp" when a C++ std::string is assigned the return value of getenv(). --- demos/xcb_nvidia.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/xcb_nvidia.cpp b/demos/xcb_nvidia.cpp index 5ecd088..5a35d93 100644 --- a/demos/xcb_nvidia.cpp +++ b/demos/xcb_nvidia.cpp @@ -37,11 +37,11 @@ std::deque g_xcbIds; xcb_connection_t * xcb_connect(const char *displayname, int *screenp) { - std::string xglNvidia = getenv(DRIVER_PATH_ENV); + std::string xglNvidia = (getenv(DRIVER_PATH_ENV) == NULL) ? "" : getenv(DRIVER_PATH_ENV); xglNvidia += "\\xgl_nvidia.dll"; HMODULE module = LoadLibrary(xglNvidia.c_str()); if (!module) { - std::string xglNulldrv = getenv("LIBXGL_DRIVERS_PATH"); + std::string xglNulldrv = (getenv("XGL_DRIVERS_PATH") == NULL) ? "" : getenv("LIBXGL_DRIVERS_PATH"); xglNulldrv += "\\xgl_nulldrv.dll"; module = LoadLibrary(xglNulldrv.c_str()); } -- 2.7.4