[svn-commits] mnicholson: branch 1.6.2 r287558 - in /branches/1.6.2: ./ main/pbx.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Sep 20 10:56:25 CDT 2010


Author: mnicholson
Date: Mon Sep 20 10:56:21 2010
New Revision: 287558

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=287558
Log:
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:
    branches/1.6.2/   (props changed)
    branches/1.6.2/main/pbx.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: branches/1.6.2/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/main/pbx.c?view=diff&rev=287558&r1=287557&r2=287558
==============================================================================
--- branches/1.6.2/main/pbx.c (original)
+++ branches/1.6.2/main/pbx.c Mon Sep 20 10:56:21 2010
@@ -3859,18 +3859,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)) {
@@ -3878,8 +3883,6 @@
 			}
 		}
 
-		ast_free(dup);
-
 		if (!cur) {
 			continue;
 		}
@@ -3907,6 +3910,7 @@
 	}
 	AST_RWLIST_UNLOCK(&hints);
 	ast_unlock_contexts();
+	ast_free(str);
 	ast_free(sc);
 	return 0;
 }




More information about the svn-commits mailing list