[asterisk-commits] rmudgett: trunk r403546 - in /trunk: ./ res/res_sorcery_astdb.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 9 12:50:22 CST 2013
Author: rmudgett
Date: Mon Dec 9 12:50:20 2013
New Revision: 403546
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403546
Log:
res_sorcery_astdb.c: Fix get multiple records by regex.
* Fix sorcery_astdb_retrieve_regex() pattern matching. Let the regexec()
function match the stored key values instead of having astdb prefilter
them. Previoiusly you could only use a simple regex pattern when the
pattern began with '^'.
* Fix off nominal memory leak in sorcery_astdb_retrieve_regex().
........
Merged revisions 403545 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/res/res_sorcery_astdb.c
Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Mon Dec 9 12:50:20 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403398,403435,403458,403510,403527,403541-403542
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403398,403435,403458,403510,403527,403541-403542,403545
Modified: trunk/res/res_sorcery_astdb.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_sorcery_astdb.c?view=diff&rev=403546&r1=403545&r2=403546
==============================================================================
--- trunk/res/res_sorcery_astdb.c (original)
+++ trunk/res/res_sorcery_astdb.c Mon Dec 9 12:50:20 2013
@@ -218,20 +218,14 @@
static void sorcery_astdb_retrieve_regex(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *regex)
{
const char *prefix = data;
- char family[strlen(prefix) + strlen(type) + 2], tree[strlen(regex) + 1];
+ char family[strlen(prefix) + strlen(type) + 2];
RAII_VAR(struct ast_db_entry *, entries, NULL, ast_db_freetree);
regex_t expression;
struct ast_db_entry *entry;
snprintf(family, sizeof(family), "%s/%s", prefix, type);
- if (regex[0] == '^') {
- snprintf(tree, sizeof(tree), "%s%%", regex + 1);
- } else {
- tree[0] = '\0';
- }
-
- if (!(entries = ast_db_gettree(family, tree)) || regcomp(&expression, regex, REG_EXTENDED | REG_NOSUB)) {
+ if (!(entries = ast_db_gettree(family, NULL)) || regcomp(&expression, regex, REG_EXTENDED | REG_NOSUB)) {
return;
}
@@ -249,6 +243,7 @@
!(objset = sorcery_json_to_objectset(json)) ||
!(object = ast_sorcery_alloc(sorcery, type, key)) ||
ast_sorcery_objectset_apply(sorcery, object, objset)) {
+ regfree(&expression);
return;
}
More information about the asterisk-commits
mailing list