Index: main/app.c =================================================================== --- main/app.c (revision 241185) +++ main/app.c (working copy) @@ -1091,28 +1091,35 @@ int ast_app_group_match_get_count(const char *groupmatch, const char *category) { struct ast_group_info *gi = NULL; - regex_t regexbuf; + regex_t regexbuf_group; + regex_t regexbuf_category; int count = 0; - - if (ast_strlen_zero(groupmatch)) { + + if (ast_strlen_zero(groupmatch)) return 0; - } - + /* if regex compilation fails, return zero matches */ - if (regcomp(®exbuf, groupmatch, REG_EXTENDED | REG_NOSUB)) { + if (regcomp(®exbuf_group, groupmatch, REG_EXTENDED | REG_NOSUB)) { + ast_log(LOG_ERROR, "Regex compile failed on: %s\n", groupmatch); return 0; } - + + if (regcomp(®exbuf_category, category, REG_EXTENDED | REG_NOSUB)) { + ast_log(LOG_ERROR, "Regex compile failed on: %s\n", category); + return 0; + } + AST_RWLIST_RDLOCK(&groups); AST_RWLIST_TRAVERSE(&groups, gi, group_list) { - if (!regexec(®exbuf, gi->group, 0, NULL, 0) && (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))) { + if (!regexec(®exbuf_group, gi->group, 0, NULL, 0) && (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !regexec(®exbuf_category, gi->category, 0, NULL, 0)))) { count++; } } AST_RWLIST_UNLOCK(&groups); - - regfree(®exbuf); - + + regfree(®exbuf_group); + regfree(®exbuf_category); + return count; }