]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use ast_dynamic_str when processing hint state changes
authorMatthew Nicholson <mnicholson@digium.com>
Mon, 20 Sep 2010 15:48:14 +0000 (15:48 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Mon, 20 Sep 2010 15:48:14 +0000 (15:48 +0000)
(related to issue #17928)
Reported by: mdu113

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@287555 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/pbx.c

index c232b9bb2092431868194872e9da02225a4d7043..ed0a3e5291f388c1bd51ad688de4257a7c2c299a 100644 (file)
@@ -2011,25 +2011,28 @@ int ast_extension_state(struct ast_channel *c, const char *context, const char *
 void ast_hint_state_changed(const char *device)
 {
        struct ast_hint *hint;
+       struct ast_dynamic_str *str;
+
+       if (!(str = ast_dynamic_str_create(1024))) {
+               return;
+       }
 
        ast_rdlock_contexts();
        AST_LIST_LOCK(&hints);
 
        AST_LIST_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_dynamic_str_set(&str, 0, "%s", ast_get_extension_app(hint->exten));
+               parse = str->str;
+
                while ( (cur = strsep(&parse, "&")) ) {
                        if (!strcasecmp(cur, device))
                                break;
                }
 
-               ast_free(dup);
-
                if (!cur)
                        continue;
 
@@ -2054,6 +2057,7 @@ void ast_hint_state_changed(const char *device)
 
        AST_LIST_UNLOCK(&hints);
        ast_unlock_contexts();
+       ast_free(str);
 }
 
 /*! \brief  ast_extension_state_add: Add watcher for extension states */