[asterisk-commits] mnicholson: trunk r287560 - in /trunk: ./ main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 20 10:57:57 CDT 2010


Author: mnicholson
Date: Mon Sep 20 10:57:52 2010
New Revision: 287560

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=287560
Log:
Merged revisions 287559 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r287559 | mnicholson | 2010-09-20 10:57:14 -0500 (Mon, 20 Sep 2010) | 21 lines
  
  Merged revisions 287558 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ................
    r287558 | mnicholson | 2010-09-20 10:56:21 -0500 (Mon, 20 Sep 2010) | 14 lines
    
    Use ast_str when processing hint state changes
    
    Merged revisions 287555 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r287555 | mnicholson | 2010-09-20 10:48:14 -0500 (Mon, 20 Sep 2010) | 5 lines
      
      Use ast_dynamic_str when processing hint state changes
      
      (related to issue #17928)
      Reported by: mdu113
    ........
  ................
................

Modified:
    trunk/   (props changed)
    trunk/main/pbx.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=287560&r1=287559&r2=287560
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Mon Sep 20 10:57:52 2010
@@ -4218,18 +4218,23 @@
 static int handle_statechange(void *datap)
 {
 	struct ast_hint *hint;
+	struct ast_str *str;
 	struct statechange *sc = datap;
+
+	if (!(str = ast_str_create(1024))) {
+		return -1;
+	}
 
 	ast_rdlock_contexts();
 	AST_RWLIST_RDLOCK(&hints);
 
 	AST_RWLIST_TRAVERSE(&hints, hint, list) {
 		struct ast_state_cb *cblist;
-		/* can't use ast_strdupa() here because we may run out of stack
-		 * space while looping over a large number of large strings */
-		char *dup = ast_strdup(ast_get_extension_app(hint->exten));
-		char *cur, *parse = dup;
+		char *cur, *parse;
 		int state;
+
+		ast_str_set(&str, 0, "%s", ast_get_extension_app(hint->exten));
+		parse = str->str;
 
 		while ( (cur = strsep(&parse, "&")) ) {
 			if (!strcasecmp(cur, sc->dev)) {
@@ -4237,8 +4242,6 @@
 			}
 		}
 
-		ast_free(dup);
-
 		if (!cur) {
 			continue;
 		}
@@ -4266,6 +4269,7 @@
 	}
 	AST_RWLIST_UNLOCK(&hints);
 	ast_unlock_contexts();
+	ast_free(str);
 	ast_free(sc);
 	return 0;
 }




More information about the asterisk-commits mailing list