regex_t regexbuf_category;
int count = 0;
- if (ast_strlen_zero(groupmatch))
+ if (ast_strlen_zero(groupmatch)) {
+ ast_log(LOG_NOTICE, "groupmatch empty\n");
return 0;
+ }
/* if regex compilation fails, return zero matches */
if (regcomp(®exbuf_group, groupmatch, REG_EXTENDED | REG_NOSUB)) {
return 0;
}
- if (regcomp(®exbuf_category, category, REG_EXTENDED | REG_NOSUB)) {
+ if (!ast_strlen_zero(category) && regcomp(®exbuf_category, category, REG_EXTENDED | REG_NOSUB)) {
ast_log(LOG_ERROR, "Regex compile failed on: %s\n", category);
return 0;
}
AST_RWLIST_UNLOCK(&groups);
regfree(®exbuf_group);
- regfree(®exbuf_category);
+ if (!ast_strlen_zero(category)) {
+ regfree(®exbuf_category);
+ }
return count;
}