Closed rombust closed 3 months ago
Classic example of old code.
Today I'd write it like this:
std::vector<GLint> array_lengths(sources.size());
std::vector<GLcchar*> array_sources(sources.size());
for (size_t i = 0; i < sources.size(); i++)
{
array_lengths[i] = sources[i].length();
array_sources[i] = (GLchar*)sources[i].c_str();
}
glShaderSource(handle, sources.size(), array_sources.data(), array_lengths.data());
Fixed
In https://github.com/sphair/ClanLib/blob/master/Sources/GL/GL3/gl3_shader_object_provider.cpp
The following code is suspect. Nothing deletes array_sources and array_source_lengths (excluding the caught exception) In addition, Visual Studio code analysis says "Buffer overrun while writing to array_source_length" in the for loop, but it all looks good to me