Hello,

The attached patch fixes a possible segmentation fault in OSG 3.5.1 in osg::LightModel that is triggered by glGetString() returning NULL. It's still not really thread safe, as before, but safe enough.


--
Mit freundlichen Grüßen,

Christoph Weiß

WSoptics GmbH
we...@wsoptics.de
+49 8868 181 997 3
Zugspitzstraße 9
86972 Altenstadt

HRB 204558  Gerichtsstand: München B  Ust.Id.Nr.: DE289079930
Geschäftsführer: Florian Sepp, Dr. Christoph Weiß
diff -ur a/src/osg/LightModel.cpp b/src/osg/LightModel.cpp
--- a/src/osg/LightModel.cpp	2012-03-21 18:36:20.000000000 +0100
+++ b/src/osg/LightModel.cpp	2016-09-22 15:08:14.760130788 +0200
@@ -58,7 +58,8 @@
 
     glLightModelfv(GL_LIGHT_MODEL_AMBIENT,_ambient.ptr());
 
-    static bool s_separateSpecularSupported = strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0;
+    static const GLubyte * const s_glVersion = glGetString(GL_VERSION);
+    static const bool s_separateSpecularSupported = s_glVersion && strncmp(reinterpret_cast<const char*>(s_glVersion),"1.2",3)>=0;
     if (s_separateSpecularSupported)
     {
         if (_colorControl==SEPARATE_SPECULAR_COLOR)
_______________________________________________
osg-submissions mailing list
osg-submissions@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to