]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't impose an arbitrary limit on member lines in queues.conf
authorMark Michelson <mmichelson@digium.com>
Fri, 24 Jul 2009 19:24:28 +0000 (19:24 +0000)
committerMark Michelson <mmichelson@digium.com>
Fri, 24 Jul 2009 19:24:28 +0000 (19:24 +0000)
I know what some of you are thinking: "UGH! Mark, why are you using
ast_strdup and ast_free for the string when you can just use ast_strdupa
and let the memory free itself?! Have the bats been chewing on your brain
again?"

Based on past experiences, I don't like using ast_strdupa inside a loop.
It's a good way to potentially exhaust stack space. Also, since this only
happens when reloading queues, I don't think that heap allocations and
frees are going to be a huge problem.

(closes issue #15559)
Reported by: amorsen

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

apps/app_queue.c

index 28958969c591978ced46a4863f87499b417b9a55..92bc978527e861060606adc38199848f872fe724 100644 (file)
@@ -4365,7 +4365,7 @@ static int reload_queues(void)
        struct ao2_iterator mem_iter;
        int new;
        const char *general_val = NULL;
-       char parse[80];
+       char *parse;
        char *interface, *state_interface;
        char *membername = NULL;
        int penalty;
@@ -4450,7 +4450,9 @@ static int reload_queues(void)
                                                }
 
                                                /* Add a new member */
-                                               ast_copy_string(parse, var->value, sizeof(parse));
+                                               if (!(parse = ast_strdup(var->value))) {
+                                                       continue;
+                                               }
                                                
                                                AST_NONSTANDARD_APP_ARGS(args, parse, ',');
 
@@ -4496,6 +4498,7 @@ static int reload_queues(void)
                                                else {
                                                        q->membercount++;
                                                }
+                                               ast_free(parse);
                                        } else {
                                                queue_set_param(q, var->name, var->value, var->lineno, 1);
                                        }