From 9d63f08472fa199ea6bdf581c88f13d3adf43a3d Mon Sep 17 00:00:00 2001 From: vrld Date: Fri, 4 Nov 2011 19:08:37 +0100 Subject: [PATCH] Make GLSL compiler messages NULL-terminated strings, even if they already are. --- src/modules/graphics/opengl/PixelEffect.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/graphics/opengl/PixelEffect.cpp b/src/modules/graphics/opengl/PixelEffect.cpp index 7f894b3a1..1a42bfd89 100644 --- a/src/modules/graphics/opengl/PixelEffect.cpp +++ b/src/modules/graphics/opengl/PixelEffect.cpp @@ -1,8 +1,5 @@ #include "PixelEffect.h" #include "GLee.h" -#include -#include -#include namespace { @@ -144,10 +141,13 @@ namespace opengl std::string PixelEffect::getWarnings() const { - GLint strlen; + GLint strlen, nullpos; glGetProgramiv(_program, GL_INFO_LOG_LENGTH, &strlen); - char *temp_str = new char[strlen]; - glGetProgramInfoLog(_program, strlen, NULL, temp_str); + char *temp_str = new char[strlen+1]; + // be extra sure that the error string will be 0-terminated + memset(temp_str, '\0', strlen+1); + glGetProgramInfoLog(_program, strlen, &nullpos, temp_str); + temp_str[nullpos] = '\0'; std::string warnings(temp_str); delete[] temp_str;