Review Board 1.7.16


va_args cleanup in res_config_odbc, res_config_curl, utils, and also res_config_pgsql

Review Request #1848 - Created April 5, 2012 and submitted

Jonathan Rose
1.8
ASTERISK-19451
Reviewers
asterisk-dev
mjordan, mmichelson, wdoekes
Asterisk
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.
None to speak of.  It compiles, but I'm really not sure how to check for va_arg leaks and such.  I'm not too worried about res_config_odbc and utils since those changes are pretty self-contained. The other changes should be fine too since the paramater ap in res_config_odbc isn't ended in any of the adapter functions there. I'm a little wary though that they should be copying to a new va_arg list instead like res_config_odbc does.

Diff revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

1 2
1 2

  1. /branches/1.8/main/utils.c: Loading...
  2. /branches/1.8/res/res_config_curl.c: Loading...
  3. /branches/1.8/res/res_config_odbc.c: Loading...
  4. /branches/1.8/res/res_config_pgsql.c: Loading...
/branches/1.8/main/utils.c
Revision 361291 New Change
[20] 1752 lines
[+20] [+] void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr,
1753
		available = space - ast_alignof(ast_string_field_allocation);
1753
		available = space - ast_alignof(ast_string_field_allocation);
1754
	}
1754
	}
1755

    
   
1755

   
1756
	needed = vsnprintf(target, available, format, ap1) + 1;
1756
	needed = vsnprintf(target, available, format, ap1) + 1;
1757

    
   
1757

   
1758
	va_end(ap1);

   
1759

    
   

   
1760
	if (needed > available) {
1758
	if (needed > available) {
1761
		/* the allocation could not be satisfied using the field's current allocation
1759
		/* the allocation could not be satisfied using the field's current allocation
1762
		   (if it has one), or the space available in the pool (if it does not). allocate
1760
		   (if it has one), or the space available in the pool (if it does not). allocate
1763
		   space for it, adding a new string pool if necessary.
1761
		   space for it, adding a new string pool if necessary.
1764
		*/
1762
		*/
[+20] [20] 370 lines
/branches/1.8/res/res_config_curl.c
Revision 361291 New Change
 
/branches/1.8/res/res_config_odbc.c
Revision 361291 New Change
 
/branches/1.8/res/res_config_pgsql.c
Revision 361291 New Change
 
  1. /branches/1.8/main/utils.c: Loading...
  2. /branches/1.8/res/res_config_curl.c: Loading...
  3. /branches/1.8/res/res_config_odbc.c: Loading...
  4. /branches/1.8/res/res_config_pgsql.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.