]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8720 #resolve [Segmentation Fault when switch_channel_str2cause is called]
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 12 Jan 2016 22:29:37 +0000 (16:29 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 12 Jan 2016 22:29:44 +0000 (16:29 -0600)
src/switch_channel.c

index c989ce2cb3b7828dab892c46a91b7c3ab6098d4a..bd6b61a032b370b39b225442d2f6822dbb2808e1 100644 (file)
@@ -204,18 +204,21 @@ SWITCH_DECLARE(const char *) switch_channel_cause2str(switch_call_cause_t cause)
 SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(const char *str)
 {
        uint8_t x;
-       switch_call_cause_t cause = SWITCH_CAUSE_NONE;
+       switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
-       if (*str > 47 && *str < 58) {
-               cause = atoi(str);
-       } else {
-               for (x = 0; x < (sizeof(CAUSE_CHART) / sizeof(struct switch_cause_table)) - 1 && CAUSE_CHART[x].name; x++) {
-                       if (!strcasecmp(CAUSE_CHART[x].name, str)) {
-                               cause = CAUSE_CHART[x].cause;
-                               break;
+       if (!zstr(str)) {
+               if (*str > 47 && *str < 58) {
+                       cause = atoi(str);
+               } else {
+                       for (x = 0; x < (sizeof(CAUSE_CHART) / sizeof(struct switch_cause_table)) - 1 && CAUSE_CHART[x].name; x++) {
+                               if (!strcasecmp(CAUSE_CHART[x].name, str)) {
+                                       cause = CAUSE_CHART[x].cause;
+                                       break;
+                               }
                        }
                }
        }
+
        return cause;
 }