From: Kenneth Graunke Date: Fri, 30 Jul 2010 20:24:50 +0000 (-0700) Subject: glcpp: Don't look for backslashes before the beginning of the string. X-Git-Tag: 062012170305~10660^2~192 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=805cbf39224580fdb85b09a21be7cbc658f0ecf6;p=profile%2Fivi%2Fmesa.git glcpp: Don't look for backslashes before the beginning of the string. Fixes a valgrind error. --- diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index 1ce829a..7aa1a96 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -93,12 +93,16 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader) const char *newline; while ((newline = strchr(search_start, '\n')) != NULL) { const char *backslash = NULL; + + /* # of characters preceding the newline. */ + int n = newline - shader; + /* Find the preceding '\', if it exists */ - if (newline[-1] == '\\') { + if (n >= 1 && newline[-1] == '\\') backslash = newline - 1; - } else if (newline[-1] == '\r' && newline[-2] == '\\') { + else if (n >= 2 && newline[-1] == '\r' && newline[-2] == '\\') backslash = newline - 2; - } + /* Double backslashes don't count (the backslash is escaped) */ if (backslash != NULL && backslash[-1] == '\\') { backslash = NULL;