]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 287558 via svnmerge from
authorMatthew Nicholson <mnicholson@digium.com>
Mon, 20 Sep 2010 15:57:14 +0000 (15:57 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Mon, 20 Sep 2010 15:57:14 +0000 (15:57 +0000)
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
  ........
................

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

main/pbx.c

index 1be93f2d714d64ddd5b44d626626af6c047a2cea..4251d1207b5c3852b7b0bbeaa1865f3b21a0cee8 100644 (file)
@@ -4218,27 +4218,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;
                }
@@ -4266,6 +4269,7 @@ static int handle_statechange(void *datap)
        }
        AST_RWLIST_UNLOCK(&hints);
        ast_unlock_contexts();
+       ast_free(str);
        ast_free(sc);
        return 0;
 }