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

@@ -348,7 +348,6 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "Postgres detected invalid input: '%s'\n", newval);
va_end(ap);
return NULL;
}
@@ -363,13 +362,11 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "Postgres detected invalid input: '%s'\n", newval);
va_end(ap);
return NULL;
}
ast_str_append(&sql, 0, " AND %s%s '%s'", newparam, op, ast_str_buffer(escapebuf));
}
va_end(ap);
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
@@ -506,7 +503,6 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "Postgres detected invalid input: '%s'\n", newval);
va_end(ap);
ast_config_destroy(cfg);
return NULL;
}
@@ -522,7 +518,6 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "Postgres detected invalid input: '%s'\n", newval);
va_end(ap);
ast_config_destroy(cfg);
return NULL;
}
@@ -534,7 +529,6 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
ast_str_append(&sql, 0, " ORDER BY %s", initfield);
}
va_end(ap);
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
@@ -678,7 +672,6 @@ static int update_pgsql(const char *database, const char *tablename, const char
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "Postgres detected invalid input: '%s'\n", newval);
va_end(ap);
release_table(table);
return -1;
}
@@ -695,20 +688,17 @@ static int update_pgsql(const char *database, const char *tablename, const char
ESCAPE_STRING(escapebuf, newval);
if (pgresult) {
ast_log(LOG_ERROR, "Postgres detected invalid input: '%s'\n", newval);
va_end(ap);
release_table(table);
return -1;
}
ast_str_append(&sql, 0, ", %s = '%s'", newparam, ast_str_buffer(escapebuf));
}
va_end(ap);
release_table(table);
ESCAPE_STRING(escapebuf, lookup);
if (pgresult) {
ast_log(LOG_ERROR, "Postgres detected invalid input: '%s'\n", lookup);
va_end(ap);
return -1;
}
@@ -955,7 +945,6 @@ static int store_pgsql(const char *database, const char *table, va_list ap)
ESCAPE_STRING(buf, newval);
ast_str_append(&sql2, 0, ", '%s'", ast_str_buffer(buf));
}
va_end(ap);
ast_str_append(&sql1, 0, "%s)", ast_str_buffer(sql2));
ast_debug(1, "PostgreSQL RealTime: Insert SQL: %s\n", ast_str_buffer(sql1));
@@ -1054,7 +1043,6 @@ static int destroy_pgsql(const char *database, const char *table, const char *ke
ESCAPE_STRING(buf2, newval);
ast_str_append(&sql, 0, " AND %s = '%s'", ast_str_buffer(buf1), ast_str_buffer(buf2));
}
va_end(ap);
ast_debug(1, "PostgreSQL RealTime: Delete SQL: %s\n", ast_str_buffer(sql));