]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use ast_str when processing hint state changes
authorMatthew Nicholson <mnicholson@digium.com>
Mon, 20 Sep 2010 15:56:21 +0000 (15:56 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Mon, 20 Sep 2010 15:56:21 +0000 (15:56 +0000)
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
........

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

main/pbx.c

index 7949eb145be852db0c2006dde52ad7b4cf52f355..7a2e0eb4be6c89bfb8b716e8f2c808777f3c0bdf 100644 (file)
@@ -3859,27 +3859,30 @@ int ast_extension_state(struct ast_channel *c, const char *context, const char *
 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)) {
                                break;
                        }
                }
 
-               ast_free(dup);
-
                if (!cur) {
                        continue;
                }
@@ -3907,6 +3910,7 @@ static int handle_statechange(void *datap)
        }
        AST_RWLIST_UNLOCK(&hints);
        ast_unlock_contexts();
+       ast_free(str);
        ast_free(sc);
        return 0;
 }