]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
we always have the caller profile at this point, if for some reason we don't just...
authorMichael Jerris <mike@jerris.com>
Wed, 30 Apr 2014 12:50:29 +0000 (08:50 -0400)
committerMichael Jerris <mike@jerris.com>
Wed, 30 Apr 2014 12:50:29 +0000 (08:50 -0400)
src/mod/applications/mod_lcr/mod_lcr.c

index 2793a5e529c1267ccc212369f07fc489c00533ec..895b10db9c09a1f33dc3d8ff9534bb0a4664d556 100644 (file)
@@ -1594,6 +1594,11 @@ SWITCH_STANDARD_DIALPLAN(lcr_dialplan_hunt)
                caller_profile = switch_channel_get_caller_profile(channel);
        }
 
+       if (!caller_profile) {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No caller profile!\n");
+               goto end;
+       }
+
        if (!(routes.profile = locate_profile(caller_profile->context))) {
                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Unknown profile: %s\n", caller_profile->context);
                goto end;
@@ -1602,14 +1607,12 @@ SWITCH_STANDARD_DIALPLAN(lcr_dialplan_hunt)
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "LCR Lookup on %s using profile %s\n", caller_profile->destination_number, caller_profile->context);
        routes.lookup_number = caller_profile->destination_number;
 
-       if (caller_profile) {
-               routes.cid = (char *) switch_channel_get_variable(channel, "effective_caller_id_number");
-               if (!routes.cid) {
-                       routes.cid = (char *) caller_profile->caller_id_number;
-               }
+       routes.cid = (char *) switch_channel_get_variable(channel, "effective_caller_id_number");
+       if (!routes.cid) {
+               routes.cid = (char *) caller_profile->caller_id_number;
        }
 
-       if (caller_profile && lcr_do_lookup(&routes) == SWITCH_STATUS_SUCCESS) {
+       if (lcr_do_lookup(&routes) == SWITCH_STATUS_SUCCESS) {
                if ((extension = switch_caller_extension_new(session, caller_profile->destination_number, caller_profile->destination_number)) == 0) {
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "memory error!\n");
                        goto end;
@@ -1644,7 +1647,8 @@ SWITCH_STANDARD_DIALPLAN(lcr_dialplan_hunt)
                        switch_caller_extension_add_application(session, extension, app, argc);
                }
        } else {
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "LCR lookup failed for %s using profile %s\n", caller_profile ? caller_profile->destination_number : "unknown", caller_profile ? caller_profile->context : "unknown");
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "LCR lookup failed for %s using profile %s\n",
+                                                 caller_profile->destination_number, caller_profile->context);
        }
 
 end: