cogl/gl: Handle bogus glGetString(GL_RENDERER) return values

Seems glGetString(GL_RENDERER) in the wild can return NULL, causing
issues with strstr(). Handle this more gracefully by using
g_return_val_if_fail(), that assumes a NULL renderer means software
rendering.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
This commit is contained in:
Jonas Ådahl 2021-07-14 16:48:34 +02:00
parent b65555a958
commit e4375046e0

View File

@ -460,6 +460,13 @@ _cogl_driver_gl_is_hardware_accelerated (CoglContext *ctx)
const char *renderer = (const char *) ctx->glGetString (GL_RENDERER);
gboolean software;
if (!renderer)
{
g_warning ("OpenGL driver returned NULL as the renderer, "
"something is wrong");
return TRUE;
}
software = strstr (renderer, "llvmpipe") != NULL ||
strstr (renderer, "softpipe") != NULL ||
strstr (renderer, "software rasterizer") != NULL ||