提交 44450cb0 authored 作者: Anthony Minessale's avatar Anthony Minessale

fix some small mem leaks

上级 25fe16df
...@@ -4920,6 +4920,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile) ...@@ -4920,6 +4920,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL, NULL); switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL, NULL);
} }
free(test_sql);
test_sql = switch_mprintf("delete from sip_presence where hostname='%q' ", mod_sofia_globals.hostname); test_sql = switch_mprintf("delete from sip_presence where hostname='%q' ", mod_sofia_globals.hostname);
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) { if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
......
...@@ -536,6 +536,9 @@ SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel) ...@@ -536,6 +536,9 @@ SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel)
switch_safe_free(pop); switch_safe_free(pop);
} }
switch_core_hash_destroy(&channel->private_hash); switch_core_hash_destroy(&channel->private_hash);
if (channel->app_flag_hash) {
switch_core_hash_destroy(&channel->app_flag_hash);
}
switch_mutex_lock(channel->profile_mutex); switch_mutex_lock(channel->profile_mutex);
switch_event_destroy(&channel->variables); switch_event_destroy(&channel->variables);
switch_mutex_unlock(channel->profile_mutex); switch_mutex_unlock(channel->profile_mutex);
......
...@@ -425,11 +425,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t ...@@ -425,11 +425,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t
switch (dbh->type) { switch (dbh->type) {
case SCDB_TYPE_ODBC: case SCDB_TYPE_ODBC:
{ {
switch_odbc_statement_handle_t stmt = NULL; status = switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, sql, NULL, &errmsg);
if ((status = switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, sql, &stmt, NULL)) != SWITCH_STATUS_SUCCESS) {
errmsg = switch_odbc_handle_get_error(dbh->native_handle.odbc_dbh, stmt);
}
switch_odbc_statement_handle_free(&stmt);
} }
break; break;
case SCDB_TYPE_CORE_DB: case SCDB_TYPE_CORE_DB:
......
...@@ -160,6 +160,11 @@ static int db_is_up(switch_odbc_handle_t *handle) ...@@ -160,6 +160,11 @@ static int db_is_up(switch_odbc_handle_t *handle)
strcpy((char *) sql, "select 1"); strcpy((char *) sql, "select 1");
} }
if (stmt) {
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
stmt = NULL;
}
if (SQLAllocHandle(SQL_HANDLE_STMT, handle->con, &stmt) != SQL_SUCCESS) { if (SQLAllocHandle(SQL_HANDLE_STMT, handle->con, &stmt) != SQL_SUCCESS) {
code = __LINE__; code = __LINE__;
goto error; goto error;
...@@ -370,12 +375,12 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec_string(switch_odbc_ ...@@ -370,12 +375,12 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec_string(switch_odbc_
SQLGetData(stmt, 1, SQL_C_CHAR, (SQLCHAR *) resbuf, (SQLLEN) len, NULL); SQLGetData(stmt, 1, SQL_C_CHAR, (SQLCHAR *) resbuf, (SQLLEN) len, NULL);
sstatus = SWITCH_ODBC_SUCCESS; sstatus = SWITCH_ODBC_SUCCESS;
} else {
return sstatus;
} }
done: done:
switch_odbc_statement_handle_free(&stmt); switch_odbc_statement_handle_free(&stmt);
return sstatus; return sstatus;
#else #else
return SWITCH_ODBC_FAIL; return SWITCH_ODBC_FAIL;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论