[Bug 97321] Query INFO_LOG_LENGTH for empty info log should return 0
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Thu Aug 18 09:34:01 UTC 2016
https://bugs.freedesktop.org/show_bug.cgi?id=97321
--- Comment #12 from Qiankun Miao <qiankun.miao at intel.com> ---
(In reply to Ian Romanick from comment #9)
> I guess the point is that you can't change one and not change the other. I
> will not budge on that.
>
> I also think it is wrong for glGetProgramInfoLog to not write a NUL when the
> info log is empty. An application that does something like
>
>
> glGetProgramInfoLog(prog, max_length, NULL, log);
> printf("Info log:\n%s\n", log);
>
> will print whatever garbage happens to be in log. You may argue that the
> application is incorrect, but this usage is very, very common (among users
> of glGetProgramInfoLog).
max_length should make sure "log" doesn't overflow, otherwise it's a bug of
glGetProgramInfoLog implementation.
Here is the usage of these two apis in chrome:
void Program::UpdateLogInfo() {
GLint max_len = 0;
glGetProgramiv(service_id_, GL_INFO_LOG_LENGTH, &max_len);
if (max_len == 0) {
set_log_info(nullptr);
return;
}
std::unique_ptr<char[]> temp(new char[max_len]);
GLint len = 0;
glGetProgramInfoLog(service_id_, max_len, &len, temp.get());
DCHECK(max_len == 0 || len < max_len);
DCHECK(len == 0 || temp[len] == '\0');
std::string log(temp.get(), len);
log = ProcessLogInfo(log);
set_log_info(log.empty() ? nullptr : log.c_str());
}
Application should handle max_len returned 0. If application didn't handle
that, glGetProgramInfoLog should make sure no buffer overflow for "max_len ==
0".
--
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/intel-3d-bugs/attachments/20160818/6156b321/attachment-0001.html>
More information about the intel-3d-bugs
mailing list