#727175 libsoil crashes when calling most functions

Package:
libsoil1
Source:
libsoil
Description:
Simple OpenGL Image Library
Submitter:
Brandon
Date:
2013-10-27 21:27:15 UTC
Severity:
important
#727175#5
Date:
2013-10-23 02:25:44 UTC
From:
To:
libsoil crashes when executing most functions. The problem is that some
internal functions use glGetString improperly, glGetString then returns
a null pointer, and then those functions send that null pointer to
strstr, which causes a crash.

I have attached a patch which replaces glGetString with glGetIntegerv
and glGetStringi, which appears to be what was intended.

I also defined GL_GLEXT_PROTOTYPES before the call to include GL.h. It
alleviates many warnings, but I'm not sure if it affects the output or
if you'd rather do it a different way.

#727175#10
Date:
2013-10-23 22:11:10 UTC
From:
To:
I did some checking, and this crash only occurs if OpenGL 3.2+ Core
profile is set. Using context version 3.1 and under, or setting the
profile to compatibility will have libsoil working properly.

#727175#15
Date:
2013-10-27 21:24:05 UTC
From:
To:
I have a new patch that is compatible with older and newer versions of
OpenGL, compatibility and core profile. Some notes:

The code has two branches, one for < GL 3.0, and one for GL 3.0+. We
determine which branch to choose at runtime, because we don't know what
GL version the end user will be linking against. We can't call
glGetStringi directly because it is only available in GL 3.0+, so we use
glXGetProcAddressARB to acquire the address of glGetStringi and to see
if it is available. It will be available if the user links against a GL
library that is 3.0+, but will not work if the context is < 3.0,
therefore we also check the running GL version. I made sure the program
doesn't crash if any GL functions return a NULL pointer, even when
they shouldn't according to current specs. This patch no longer needs
the GL_GLEXT_PROTOTYPES definition.