From 4144f2e864f1f54bd63fb6fe389a75b6247fd9f9 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 13 Mar 2023 11:46:58 +0100 Subject: [PATCH] wined3d: Don't bother explicitly terminating the GLSL info log in print_glsl_info_log(). --- dlls/wined3d/glsl_shader.c | 22 ++++++++++++++-------- dlls/wined3d/wined3d_private.h | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 594fdf73f46..1c037b78b84 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -518,29 +518,35 @@ void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLuint id, BOOL * that if there are errors. */ if (length > 1) { - const char *ptr, *line; + const char *ptr, *end, *line; log = heap_alloc(length); - /* The info log is supposed to be zero-terminated, but at least some - * versions of fglrx don't terminate the string properly. The reported - * length does include the terminator, so explicitly set it to zero - * here. */ - log[length - 1] = 0; if (program) GL_EXTCALL(glGetProgramInfoLog(id, length, NULL, log)); else GL_EXTCALL(glGetShaderInfoLog(id, length, NULL, log)); ptr = log; + /* The info log is supposed to be zero-terminated. Note that at least + * some versions of fglrx don't terminate the string properly. The + * reported length does include the supposed terminator though, so we + * don't care here. */ + end = &ptr[length - 1]; if (gl_info->quirks & WINED3D_QUIRK_INFO_LOG_SPAM) { WARN("Info log received from GLSL shader #%u:\n", id); - while ((line = get_info_log_line(&ptr))) WARN(" %.*s", (int)(ptr - line), line); + while ((line = wined3d_get_line(&ptr, end))) + { + WARN(" %.*s", (int)(ptr - line), line); + } } else { FIXME("Info log received from GLSL shader #%u:\n", id); - while ((line = get_info_log_line(&ptr))) FIXME(" %.*s", (int)(ptr - line), line); + while ((line = wined3d_get_line(&ptr, end))) + { + FIXME(" %.*s", (int)(ptr - line), line); + } } heap_free(log); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 425261a195e..0c8cc03738a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -74,6 +74,20 @@ static inline float int_to_float(uint32_t i) return u.f; } +static inline const char *wined3d_get_line(const char **ptr, const char *end) +{ + const char *p, *q; + + if ((p = *ptr) >= end) + return NULL; + + if (!(q = memchr(p, '\n', end - p))) + *ptr = end; + else + *ptr = q + 1; + return p; +} + #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu)) /* Driver quirks */ -- 2.11.4.GIT