Mesa (7.10): glsl: Fix memory error when creating the supported version string.
Kenneth Graunke
kwg at kemper.freedesktop.org
Thu May 26 17:49:25 UTC 2011
Module: Mesa
Branch: 7.10
Commit: 9286d0ddd37e64c3e8c50bb7de1bd100969a5c98
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9286d0ddd37e64c3e8c50bb7de1bd100969a5c98
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Tue Feb 1 00:20:01 2011 -0800
glsl: Fix memory error when creating the supported version string.
Passing ralloc_vasprintf_append a 0-byte allocation doesn't work. If
passed a non-NULL argument, ralloc calls strlen to find the end of the
string. Since there's no terminating '\0', it runs off the end.
Fixes a crash introduced in 14880a510a1a288df0778395097d5a52806abfb0.
(cherry-picked from commit a7d350790b4d0416117bc785aa77de52e9298a01)
---
src/glsl/glsl_parser_extras.cpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 3a17db8..3dffb33 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -97,7 +97,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx,
? 100 : 110;
const unsigned highest_version =
(ctx->API == API_OPENGL) ? ctx->Const.GLSLVersion : 100;
- char *supported = (char *) ralloc_context(this);
+ char *supported = ralloc_strdup(this, "");
for (unsigned ver = lowest_version; ver <= highest_version; ver += 10) {
const char *const prefix = (ver == lowest_version)
More information about the mesa-commit
mailing list