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,15 +117,23 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog) ...@@ -117,15 +117,23 @@ 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::vector<char> buf(infoLogLength); std::string warning;
mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]); if (infoLogLength > 0)
{
std::vector<char> buf(infoLogLength);
mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]);
mFunctions->deleteProgram(mProgramID); mFunctions->deleteProgram(mProgramID);
mProgramID = 0; mProgramID = 0;
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,14 +77,21 @@ bool ShaderGL::postTranslateCompile(gl::Compiler *compiler, std::string *infoLog ...@@ -77,14 +77,21 @@ 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);
std::vector<char> buf(infoLogLength); if (infoLogLength > 0)
mFunctions->getShaderInfoLog(mShaderID, infoLogLength, nullptr, &buf[0]); {
std::vector<char> buf(infoLogLength);
mFunctions->deleteShader(mShaderID); mFunctions->getShaderInfoLog(mShaderID, infoLogLength, nullptr, &buf[0]);
mShaderID = 0;
mFunctions->deleteShader(mShaderID);
*infoLog = &buf[0]; mShaderID = 0;
TRACE("\n%s", infoLog->c_str());
*infoLog = &buf[0];
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