summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-04-24 20:31:30 +0100
committerJosé Fonseca <jfonseca@vmware.com>2010-04-24 20:31:30 +0100
commitcca8abe20ec9d1a560cc3fc97545922254d2a574 (patch)
treeff19ee9ea47d99e890093c2c22b5e32e5f0ab2c0
parent1eeae05441f4cf77773efa7079eec1fe4b70c5d9 (diff)
mesa: Eliminate multiple va_list usage.
va_list is a mutable iterator. When passed to a function it will likely point to somewhere else. This fixes segmentation fault in glean vertProg1 on Ubuntu 9.10.
-rw-r--r--src/mesa/shader/program_parse.tab.c7
-rw-r--r--src/mesa/shader/program_parse.y7
2 files changed, 8 insertions, 6 deletions
diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c
index e5ef25ec38..99c4b2baa5 100644
--- a/src/mesa/shader/program_parse.tab.c
+++ b/src/mesa/shader/program_parse.tab.c
@@ -5557,7 +5557,6 @@ make_error_string(const char *fmt, ...)
char *str;
va_list args;
- va_start(args, fmt);
/* Call vsnprintf once to determine how large the final string is. Call it
* again to do the actual formatting. from the vsnprintf manual page:
@@ -5566,15 +5565,17 @@ make_error_string(const char *fmt, ...)
* characters printed (not including the trailing '\0' used to end
* output to strings).
*/
+ va_start(args, fmt);
length = 1 + vsnprintf(NULL, 0, fmt, args);
+ va_end(args);
str = malloc(length);
if (str) {
+ va_start(args, fmt);
vsnprintf(str, length, fmt, args);
+ va_end(args);
}
- va_end(args);
-
return str;
}
diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y
index 299e2477e4..06c2db7a07 100644
--- a/src/mesa/shader/program_parse.y
+++ b/src/mesa/shader/program_parse.y
@@ -2596,7 +2596,6 @@ make_error_string(const char *fmt, ...)
char *str;
va_list args;
- va_start(args, fmt);
/* Call vsnprintf once to determine how large the final string is. Call it
* again to do the actual formatting. from the vsnprintf manual page:
@@ -2605,15 +2604,17 @@ make_error_string(const char *fmt, ...)
* characters printed (not including the trailing '\0' used to end
* output to strings).
*/
+ va_start(args, fmt);
length = 1 + vsnprintf(NULL, 0, fmt, args);
+ va_end(args);
str = malloc(length);
if (str) {
+ va_start(args, fmt);
vsnprintf(str, length, fmt, args);
+ va_end(args);
}
- va_end(args);
-
return str;
}