diff --git a/src/mod/applications/mod_cidlookup/mod_cidlookup.c b/src/mod/applications/mod_cidlookup/mod_cidlookup.c index 5b90e8a095..7df22fb3ef 100644 --- a/src/mod/applications/mod_cidlookup/mod_cidlookup.c +++ b/src/mod/applications/mod_cidlookup/mod_cidlookup.c @@ -545,9 +545,6 @@ static cid_data_t *do_lookup(switch_memory_pool_t *pool, switch_event_t *event, cid_data_t *cidtmp = NULL; switch_bool_t save_cache = SWITCH_FALSE; - cid = switch_core_alloc(pool, sizeof(cid_data_t)); - switch_assert(cid); - number = string_digitsonly(pool, num); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "caller_id_number", number); @@ -555,6 +552,8 @@ static cid_data_t *do_lookup(switch_memory_pool_t *pool, switch_event_t *event, if (globals.odbc_dsn && globals.sql) { name = do_db_lookup(pool, event, number, globals.sql); if (name) { + cid = switch_core_alloc(pool, sizeof(cid_data_t)); + switch_assert(cid); cid->name = name; cid->src = "phone_database"; goto done; @@ -578,6 +577,11 @@ static cid_data_t *do_lookup(switch_memory_pool_t *pool, switch_event_t *event, } } + if (!cid) { + cid = switch_core_alloc(pool, sizeof(cid_data_t)); + switch_assert(cid); + } + if (!skipurl && globals.url) { url_query = switch_event_expand_headers(event, globals.url); do_lookup_url(pool, event, &name, url_query, NULL, NULL, 0); @@ -593,10 +597,6 @@ static cid_data_t *do_lookup(switch_memory_pool_t *pool, switch_event_t *event, } done: - if (!cid) { - cid = switch_core_alloc(pool, sizeof(cid_data_t)); - switch_assert(cid); - } /* append area if we can */ if (!cid->area && !skipcitystate && strlen(number) == 11 && number[0] == '1' && globals.odbc_dsn && globals.citystate_sql) {