mirror of https://github.com/sipwise/kamailio.git
- build long orderless lists in reverse (forward list building has
exponential runtime)
- fix mem leaks
Change-Id: I00aa4d6bfd3eda5b37e04e79143b74b3ebd6224e
(cherry picked from commit a57c14951f)
changes/53/33253/1
parent
26fc75dfa6
commit
b6fa96dbeb
@ -0,0 +1,81 @@
|
||||
--- a/src/modules/db_redis/redis_dbase.c
|
||||
+++ b/src/modules/db_redis/redis_dbase.c
|
||||
@@ -461,11 +461,12 @@
|
||||
LM_DBG("found suitable entry key '%.*s' for query\n",
|
||||
(*keys)->key.len, (*keys)->key.s);
|
||||
*keys_count = 1;
|
||||
- pkg_free(keyname.s);
|
||||
} else {
|
||||
LM_ERR("Failed to create direct entry key, no matching key definition\n");
|
||||
goto err;
|
||||
}
|
||||
+ if (keyname.s)
|
||||
+ pkg_free(keyname.s);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -552,11 +553,11 @@
|
||||
LM_DBG("found key '%.*s' for type '%.*s'\n",
|
||||
keyname.len, keyname.s,
|
||||
type_name->len, type_name->s);
|
||||
- pkg_free(keyname.s);
|
||||
|
||||
if (set_keys) {
|
||||
// add key for parent set
|
||||
// <version>:<table>::index::<type>
|
||||
+ pkg_free(keyname.s);
|
||||
keyname.len = table->version_code.len + table_name->len + 9 + type->type.len;
|
||||
keyname.s = pkg_malloc(keyname.len + 1);
|
||||
if (!keyname.s) {
|
||||
@@ -571,9 +572,10 @@
|
||||
LM_ERR("Failed to add query key to set key list\n");
|
||||
goto err;
|
||||
}
|
||||
- pkg_free(keyname.s);
|
||||
}
|
||||
}
|
||||
+ if (keyname.s)
|
||||
+ pkg_free(keyname.s);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -631,6 +633,9 @@
|
||||
pkg_free(keyname.s);
|
||||
keyname.s = NULL;
|
||||
} else {
|
||||
+ if (keyname.s)
|
||||
+ pkg_free(keyname.s);
|
||||
+ keyname.s = NULL;
|
||||
LM_DBG("no direct entry key found, checking type keys\n");
|
||||
for (type = table->types; type; type = type->next) {
|
||||
key = type->keys;
|
||||
@@ -674,7 +679,7 @@
|
||||
redisReply *subreply = reply->element[i];
|
||||
if (subreply->type == REDIS_REPLY_STRING) {
|
||||
LM_DBG("adding resulting entry key '%s' from type query\n", subreply->str);
|
||||
- if (db_redis_key_add_string(query_keys, subreply->str, strlen(subreply->str)) != 0) {
|
||||
+ if (db_redis_key_prepend_string(query_keys, subreply->str, strlen(subreply->str)) != 0) {
|
||||
LM_ERR("Failed to add query key\n");
|
||||
goto err;
|
||||
}
|
||||
@@ -696,6 +701,11 @@
|
||||
LM_DBG("will use key '%.*s' at offset %llx for timestamp/int range scan\n",
|
||||
keyname.len, keyname.s, (unsigned long long) *ts_scan_start);
|
||||
*ts_scan_key = keyname;
|
||||
+ keyname.s = NULL;
|
||||
+ }
|
||||
+ else if (keyname.s) {
|
||||
+ pkg_free(keyname.s);
|
||||
+ keyname.s = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2119,7 +2129,7 @@
|
||||
if (!prefix || prefix == type_key->key.s) {
|
||||
LM_DBG("Invalid key without :: '%.*s'\n",
|
||||
type_key->key.len, type_key->key.s);
|
||||
- goto error;
|
||||
+ continue;
|
||||
}
|
||||
for (new_type_key = new_type_keys; new_type_key; new_type_key = new_type_key->next) {
|
||||
// compare prefix to see if this is the same key
|
||||
Loading…
Reference in new issue