From 593cdf00ff201f83b487b731229806e6fb195ec3 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Sat, 11 Nov 2023 06:56:46 +0000 Subject: [PATCH] [GLES3] Protect against bogus `glGetShaderInfoLog` return values. On some buggy drivers `GL_INFO_LOG_LENGTH` returns incorrect values, which may lead to incorrectly filling in the log string. This could lead to uninitialized data being attempted to be printed and a crash. This PR zeros the array to ensure uninitialized data is not used. --- drivers/gles3/shader_gles3.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 77b870f8b24..75b2662a1c0 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -328,7 +328,7 @@ void ShaderGLES3::_compile_specialization(Version::Specialization &spec, uint32_ } char *ilogmem = (char *)Memory::alloc_static(iloglen + 1); - ilogmem[iloglen] = '\0'; + memset(ilogmem, 0, iloglen + 1); glGetShaderInfoLog(spec.vert_id, iloglen, &iloglen, ilogmem); String err_string = name + ": Vertex shader compilation failed:\n"; @@ -376,7 +376,7 @@ void ShaderGLES3::_compile_specialization(Version::Specialization &spec, uint32_ } char *ilogmem = (char *)Memory::alloc_static(iloglen + 1); - ilogmem[iloglen] = '\0'; + memset(ilogmem, 0, iloglen + 1); glGetShaderInfoLog(spec.frag_id, iloglen, &iloglen, ilogmem); String err_string = name + ": Fragment shader compilation failed:\n";