Commit 01ad6445 by Corentin Wallez Committed by Commit Bot

Program/ShaderGL: handle empty info logs

The GL driver can sometimes have an empty info log and return an info log length of 0. This would cause a vector to be initialized with a length of 0 just before it's .data() pointer was used, causing a segfault. BUG=angleproject:1323 Change-Id: Iaf9b569ec64a90c714a213562e427fb7cc8daa6b Reviewed-on: https://chromium-review.googlesource.com/330197Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 9cb1df4f
...@@ -117,6 +117,9 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog) ...@@ -117,6 +117,9 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog)
GLint infoLogLength = 0; GLint infoLogLength = 0;
mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength); mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength);
std::string warning;
if (infoLogLength > 0)
{
std::vector<char> buf(infoLogLength); std::vector<char> buf(infoLogLength);
mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]); mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]);
...@@ -125,7 +128,12 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog) ...@@ -125,7 +128,12 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog)
infoLog << buf.data(); infoLog << buf.data();
std::string warning = FormatString("Program link failed unexpectedly: %s", buf.data()); warning = FormatString("Program link failed unexpectedly: %s", buf.data());
}
else
{
warning = "Program link failed unexpectedly with no info log.";
}
ANGLEPlatformCurrent()->logWarning(warning.c_str()); ANGLEPlatformCurrent()->logWarning(warning.c_str());
TRACE("\n%s", warning.c_str()); TRACE("\n%s", warning.c_str());
......
...@@ -77,6 +77,8 @@ bool ShaderGL::postTranslateCompile(gl::Compiler *compiler, std::string *infoLog ...@@ -77,6 +77,8 @@ bool ShaderGL::postTranslateCompile(gl::Compiler *compiler, std::string *infoLog
GLint infoLogLength = 0; GLint infoLogLength = 0;
mFunctions->getShaderiv(mShaderID, GL_INFO_LOG_LENGTH, &infoLogLength); mFunctions->getShaderiv(mShaderID, GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 0)
{
std::vector<char> buf(infoLogLength); std::vector<char> buf(infoLogLength);
mFunctions->getShaderInfoLog(mShaderID, infoLogLength, nullptr, &buf[0]); mFunctions->getShaderInfoLog(mShaderID, infoLogLength, nullptr, &buf[0]);
...@@ -85,6 +87,11 @@ bool ShaderGL::postTranslateCompile(gl::Compiler *compiler, std::string *infoLog ...@@ -85,6 +87,11 @@ bool ShaderGL::postTranslateCompile(gl::Compiler *compiler, std::string *infoLog
*infoLog = &buf[0]; *infoLog = &buf[0];
TRACE("\n%s", infoLog->c_str()); TRACE("\n%s", infoLog->c_str());
}
else
{
TRACE("\nShader compilation failed with no info log.");
}
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment