diff --git a/modules/cachedb_cassandra/cachedb_cassandra_dbase.c b/modules/cachedb_cassandra/cachedb_cassandra_dbase.c index 580fb470405..f50cd5b0627 100644 --- a/modules/cachedb_cassandra/cachedb_cassandra_dbase.c +++ b/modules/cachedb_cassandra/cachedb_cassandra_dbase.c @@ -141,13 +141,13 @@ int cassandra_reopen(cassandra_con *cass_con) int cassandra_new_connection(cassandra_con *con, char *host, int port, char *username, char *password) { con->cluster = cass_cluster_new(); - if (username && password) { - cass_cluster_set_credentials(con->cluster, username, password); - } if (!con->cluster) { LM_ERR("Failed to create Cassandra Cluster object\n"); return -1; } + if (username && password) { + cass_cluster_set_credentials(con->cluster, username, password); + } #if CASS_VERSION_MAJOR >= 2 && CASS_VERSION_MINOR >= 15 /* since version 2.15, DSE support is available in the standard driver diff --git a/modules/cachedb_memcached/cachedb_memcached.c b/modules/cachedb_memcached/cachedb_memcached.c index 9efdfc29616..f2fd4e8eab5 100644 --- a/modules/cachedb_memcached/cachedb_memcached.c +++ b/modules/cachedb_memcached/cachedb_memcached.c @@ -400,6 +400,11 @@ memcached_con* memcached_new_connection(struct cachedb_id *id) con->ref = 1; con->memc = memcached_create(NULL); + if (!con->memc) { + LM_ERR("failed to create memcached handle\n"); + pkg_free(con); + return 0; + } memset(host_buff,0,MAX_HOSTPORT_SIZE);