]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
remove possible uninitialized memory reference on inherit_codec variable check
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 27 Mar 2009 23:50:34 +0000 (23:50 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 27 Mar 2009 23:50:34 +0000 (23:50 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12817 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_ivr_originate.c

index 0a83c2779f14d6c7d5f25dee9dd3e0f1a2c28a9c..91bb3e4ebf9681f012d0875b1f9734d241c760b1 100644 (file)
@@ -546,15 +546,18 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
        if (pindex > -1 && caller_channel && switch_channel_ready(caller_channel) && !switch_channel_media_ready(caller_channel)) {
                const char *var = switch_channel_get_variable(caller_channel, "inherit_codec");
                if (switch_true(var)) {
-                       switch_codec_implementation_t impl;
+                       switch_codec_implementation_t impl = { 0 };
                        char tmp[128] = "";
 
                        
-                       switch_core_session_get_read_impl(originate_status[pindex].peer_session, &impl);
-                       switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", impl.iananame, impl.samples_per_second, impl.microseconds_per_packet / 1000);
-                       switch_channel_set_variable(caller_channel, "absolute_codec_string", tmp);
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting codec string on %s to %s\n", switch_channel_get_name(caller_channel), tmp);
-
+                       if (switch_core_session_get_read_impl(originate_status[pindex].peer_session, &impl) == SWITCH_STATUS_SUCCESS) {
+                               switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", impl.iananame, impl.samples_per_second, impl.microseconds_per_packet / 1000);
+                               switch_channel_set_variable(caller_channel, "absolute_codec_string", tmp);
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting codec string on %s to %s\n", switch_channel_get_name(caller_channel), tmp);
+                       } else {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error inheriting codec.  Channel %s has no read codec yet.\n", 
+                                                                 switch_channel_get_name(originate_status[pindex].peer_channel));
+                       }
 
                }
        }