From 95d23e01861541d686aabd243e785ccfeeda554a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 11 Dec 2007 20:50:52 +0000 Subject: [PATCH] update sql git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6671 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_core_sqldb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 194f20a5bf..f9e6ce7556 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -154,10 +154,12 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t * thread, uint8_t trans = 0, nothing_in_queue = 0; uint32_t target = 1000; switch_size_t len = 0, sql_len = SQLLEN; - char *sqlbuf = (char *) malloc(sql_len); + char *tmp, *sqlbuf = (char *) malloc(sql_len); char *sql; switch_size_t newlen; + switch_assert(sqlbuf); + if (!sql_manager.event_db) { sql_manager.event_db = switch_core_db_handle(); } @@ -180,10 +182,12 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t * thread, itterations++; if (len + newlen > sql_len) { sql_len = len + SQLLEN; - if (!(sqlbuf = realloc(sqlbuf, sql_len))) { + if (!(tmp = realloc(sqlbuf, sql_len))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread ending on mem err\n"); + abort(); break; } + sqlbuf = tmp; } sprintf(sqlbuf + len, "%s;\n", sql); len += newlen;