From ba86c3d2f81914d10086504e0deb80780afe755d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 4 Nov 2012 17:46:04 +0100 Subject: [PATCH] Avoid crash when glGetString(GL_EXTENSIONS) returns nullptr. --- src/Context.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index e86df90df..3f6f11916 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -213,12 +213,16 @@ Context::Context() { /* OpenGL 2.1 / OpenGL ES 2.0 doesn't have glGetStringi() */ } else { - vector extensions = Corrade::Utility::split(reinterpret_cast(glGetString(GL_EXTENSIONS)), ' '); - for(const string& extension: extensions) { - auto found = futureExtensions.find(extension); - if(found != futureExtensions.end()) { - _supportedExtensions.push_back(found->second); - extensionStatus.set(found->second._index); + /* Don't crash when glGetString() returns nullptr */ + const char* e = reinterpret_cast(glGetString(GL_EXTENSIONS)); + if(e) { + vector extensions = Corrade::Utility::split(e, ' '); + for(const string& extension: extensions) { + auto found = futureExtensions.find(extension); + if(found != futureExtensions.end()) { + _supportedExtensions.push_back(found->second); + extensionStatus.set(found->second._index); + } } } }