Improve info log length checks
Extend the info log length checks to shader_utils used by tests, and
treat info log with length 1 as empty, since it can only include the
null terminator. At least the Intel GL driver may generate "\0" as
info log in some situations, for example when compiling a user-defined
function with 50000 parameters.
BUG=angleproject:1323
Change-Id: I00f2965539ec235cb949c80c2a9e1d063d32fa15
Reviewed-on: https://chromium-review.googlesource.com/331461
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/util/shader_utils.cpp b/util/shader_utils.cpp
index 150d067..62223b5 100644
--- a/util/shader_utils.cpp
+++ b/util/shader_utils.cpp
@@ -46,7 +46,9 @@
GLint infoLogLength;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
- if (infoLogLength > 0)
+ // Info log length includes the null terminator, so 1 means that the info log is an empty
+ // string.
+ if (infoLogLength > 1)
{
std::vector<GLchar> infoLog(infoLogLength);
glGetShaderInfoLog(shader, static_cast<GLsizei>(infoLog.size()), NULL, &infoLog[0]);
@@ -123,10 +125,19 @@
GLint infoLogLength;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
- std::vector<GLchar> infoLog(infoLogLength);
- glGetProgramInfoLog(program, static_cast<GLsizei>(infoLog.size()), NULL, &infoLog[0]);
+ // Info log length includes the null terminator, so 1 means that the info log is an empty
+ // string.
+ if (infoLogLength > 1)
+ {
+ std::vector<GLchar> infoLog(infoLogLength);
+ glGetProgramInfoLog(program, static_cast<GLsizei>(infoLog.size()), nullptr, &infoLog[0]);
- std::cerr << "program link failed: " << &infoLog[0];
+ std::cerr << "program link failed: " << &infoLog[0];
+ }
+ else
+ {
+ std::cerr << "program link failed. <Empty log message>";
+ }
glDeleteProgram(program);
return 0;