mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Fix issue #291: Usage of unsanitized GLSL compiler errors.
Compiler errors may contain vsprintf-escape sequences, which is used by love::Exception. Wrap errors in %s to avoid garbage output.
This commit is contained in:
@@ -80,15 +80,15 @@ namespace opengl
|
|||||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &strlen);
|
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &strlen);
|
||||||
char *error_str = new char[strlen];
|
char *error_str = new char[strlen];
|
||||||
glGetShaderInfoLog(shader, strlen, NULL, error_str);
|
glGetShaderInfoLog(shader, strlen, NULL, error_str);
|
||||||
|
std::string tmp(error_str);
|
||||||
std::stringstream error_message;
|
|
||||||
error_message << "Cannot compile shader:" << std::endl << std::string(error_str);
|
|
||||||
|
|
||||||
// cleanup before throw
|
// cleanup before throw
|
||||||
delete[] error_str;
|
delete[] error_str;
|
||||||
glDeleteShader(shader);
|
glDeleteShader(shader);
|
||||||
glDeleteProgram(_program);
|
glDeleteProgram(_program);
|
||||||
throw love::Exception(error_message.str().c_str());
|
|
||||||
|
// XXX: errorlog may contain escape sequences.
|
||||||
|
throw love::Exception("Cannot compile shader:\n%s", tmp.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// link fragment shader
|
// link fragment shader
|
||||||
@@ -99,13 +99,12 @@ namespace opengl
|
|||||||
if (GL_FALSE == link_ok) {
|
if (GL_FALSE == link_ok) {
|
||||||
// this should not happen if compiling is ok, but one can never be too careful
|
// this should not happen if compiling is ok, but one can never be too careful
|
||||||
// get linker error
|
// get linker error
|
||||||
std::stringstream error_message;
|
std::string tmp(getWarnings());
|
||||||
error_message << "Cannot compile shader:" << std::endl << getWarnings();
|
|
||||||
|
|
||||||
// cleanup before throw
|
// cleanup before throw
|
||||||
glDeleteShader(shader);
|
glDeleteShader(shader);
|
||||||
glDeleteProgram(_program);
|
glDeleteProgram(_program);
|
||||||
throw love::Exception(error_message.str().c_str());
|
throw love::Exception("Cannot compile shader:\n%s", tmp.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
glDeleteShader(shader);
|
glDeleteShader(shader);
|
||||||
|
|||||||
Reference in New Issue
Block a user