Mesa (master): glcpp: Fix post-decrement underflow in loop-control variable
Carl Worth
cworth at kemper.freedesktop.org
Mon Jun 3 20:33:53 UTC 2013
Module: Mesa
Branch: master
Commit: d8eeb1d330c52aad734cc553e41b457e6727275c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d8eeb1d330c52aad734cc553e41b457e6727275c
Author: Carl Worth <cworth at cworth.org>
Date: Mon Jun 3 11:35:43 2013 -0700
glcpp: Fix post-decrement underflow in loop-control variable
This loop-control condition with a post-decrement operator would lead to
an underflow of collapsed_newlines. This in turn would cause a subsequent
execution of the loop to labor inordinately trying to return the loop-control
variable to a value of 0 again.
Fix this by dis-intertwining the test and the decrement.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65112
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/glsl/glcpp/pp.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c
index 789f7f9..7e1b6c6 100644
--- a/src/glsl/glcpp/pp.c
+++ b/src/glsl/glcpp/pp.c
@@ -97,8 +97,10 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
{
ralloc_strncat(&clean, shader,
newline - shader + 1);
- while (collapsed_newlines--)
+ while (collapsed_newlines) {
ralloc_strcat(&clean, "\n");
+ collapsed_newlines--;
+ }
shader = newline + 1;
search_start = shader;
}
More information about the mesa-commit
mailing list