diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 8a40caab1f..36ef420366 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -444,6 +444,7 @@ void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt) } } + if (codec_string) { char *tmp_codec_string; if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) { diff --git a/src/switch_core_hash.c b/src/switch_core_hash.c index 85e9e90dd6..10da437888 100644 --- a/src/switch_core_hash.c +++ b/src/switch_core_hash.c @@ -39,18 +39,25 @@ struct switch_hash { Hash table; + switch_memory_pool_t *pool; }; SWITCH_DECLARE(switch_status_t) switch_core_hash_init_case(switch_hash_t **hash, switch_memory_pool_t *pool, switch_bool_t case_sensitive) { switch_hash_t *newhash; - newhash = switch_core_alloc(pool, sizeof(*newhash)); + if (pool) { + newhash = switch_core_alloc(pool, sizeof(*newhash)); + newhash->pool = pool; + } else { + switch_zmalloc(newhash, sizeof(*newhash)); + } + switch_assert(newhash); sqlite3HashInit(&newhash->table, case_sensitive ? SQLITE_HASH_BINARY : SQLITE_HASH_STRING, 1); *hash = newhash; - + return SWITCH_STATUS_SUCCESS; } @@ -58,7 +65,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_destroy(switch_hash_t **hash) { switch_assert(hash != NULL && *hash != NULL); sqlite3HashClear(&(*hash)->table); + + if (!(*hash)->pool) { + free(*hash); + } + *hash = NULL; + return SWITCH_STATUS_SUCCESS; }