From c1b88b3cf45525d5e99540f64767b907b9c11598 Mon Sep 17 00:00:00 2001 From: Jeff Peeler Date: Sun, 8 Jun 2008 01:16:25 +0000 Subject: [PATCH] Fixes segfault when using ParkAndAnnounce. Also, loop made more efficient as announce template only needs to be checked until the number of colon separated arguments run out, not the entire pointer storage array. Was done in a similiar fashion in 1.4, but here we're using less variables. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@121131 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_parkandannounce.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c index d1066fd2cd..45740d9015 100644 --- a/apps/app_parkandannounce.c +++ b/apps/app_parkandannounce.c @@ -144,9 +144,12 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data) ast_verb(4, "Announce Template:%s\n", args.template); - for (looptemp = 0, tmp[looptemp++] = strsep(&args.template, ":"); - looptemp < sizeof(tmp) / sizeof(tmp[0]); - tmp[looptemp++] = strsep(&args.template, ":")); + for (looptemp = 0; looptemp < sizeof(tmp) / sizeof(tmp[0]); looptemp++) { + if ((tmp[looptemp] = strsep(&args.template, ":")) != NULL) + continue; + else + break; + } for (i = 0; i < looptemp; i++) { ast_verb(4, "Announce:%s\n", tmp[i]);