Make use of va_args more appropriate to form in various res_config modules plus utils.

A number of va_copy operations weren't matched with a corresponding va_end in res_config_odbc. Also, there was a potential for va_end to be invoked twice on the same va_arg in utils, which would mean invoking va_end on an undefined variable... which is bad.
va_end is removed from various functions in config_pgsql and config_curl since they aren't making their own copy.  The invokers of those functions are responsible for calling va_end on them.

(issue ASTERISK-19451)
Reported by: Walter Doekes
Review: https://reviewboard.asterisk.org/r/1848/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@362354 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jonathan Rose
2012-04-17 20:43:22 +00:00
parent 8cbe9f9fa7
commit bcd63be3cd
4 changed files with 46 additions and 48 deletions

View File

@@ -89,7 +89,6 @@ static struct ast_variable *realtime_curl(const char *url, const char *unused, v
ast_uri_encode(newval, buf2, sizeof(buf2), EncodeSpecialChars);
ast_str_append(&query, 0, "%s%s=%s", i > 0 ? "&" : "", buf1, buf2);
}
va_end(ap);
ast_str_append(&query, 0, ")}");
ast_str_substitute_variables(&buffer, 0, NULL, ast_str_buffer(query));
@@ -170,7 +169,6 @@ static struct ast_config *realtime_multi_curl(const char *url, const char *unuse
ast_uri_encode(newval, buf2, sizeof(buf2), EncodeSpecialChars);
ast_str_append(&query, 0, "%s%s=%s", i > 0 ? "&" : "", buf1, buf2);
}
va_end(ap);
ast_str_append(&query, 0, ")}");
@@ -261,7 +259,6 @@ static int update_curl(const char *url, const char *unused, const char *keyfield
ast_uri_encode(newval, buf2, sizeof(buf2), EncodeSpecialChars);
ast_str_append(&query, 0, "%s%s=%s", i > 0 ? "&" : "", buf1, buf2);
}
va_end(ap);
ast_str_append(&query, 0, ")}");
ast_str_substitute_variables(&buffer, 0, NULL, ast_str_buffer(query));
@@ -321,7 +318,6 @@ static int update2_curl(const char *url, const char *unused, va_list ap)
ast_str_append(&query, 0, "%s%s=%s", first ? "" : "&", buf1, buf2);
first = 0;
}
va_end(ap);
ast_str_append(&query, 0, ")}");
/* Proxies work, by setting CURLOPT options in the [globals] section of
@@ -387,7 +383,6 @@ static int store_curl(const char *url, const char *unused, va_list ap)
ast_uri_encode(newval, buf2, sizeof(buf2), EncodeSpecialChars);
ast_str_append(&query, 0, "%s%s=%s", i > 0 ? "&" : "", buf1, buf2);
}
va_end(ap);
ast_str_append(&query, 0, ")}");
ast_str_substitute_variables(&buffer, 0, NULL, ast_str_buffer(query));
@@ -452,7 +447,6 @@ static int destroy_curl(const char *url, const char *unused, const char *keyfiel
ast_uri_encode(newval, buf2, sizeof(buf2), EncodeSpecialChars);
ast_str_append(&query, 0, "%s%s=%s", i > 0 ? "&" : "", buf1, buf2);
}
va_end(ap);
ast_str_append(&query, 0, ")}");
ast_str_substitute_variables(&buffer, 0, NULL, ast_str_buffer(query));
@@ -514,7 +508,6 @@ static int require_curl(const char *url, const char *unused, va_list ap)
type == RQ_FLOAT ? "float" :
"unknown", size);
}
va_end(ap);
ast_str_append(&query, 0, ")}");
ast_str_substitute_variables(&buffer, 0, NULL, ast_str_buffer(query));