FS-8720 #resolve [Segmentation Fault when switch_channel_str2cause is called]

This commit is contained in:
Anthony Minessale 2016-01-12 16:29:37 -06:00
parent 4fc4c52392
commit c01a8849a0

View 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) SWITCH_DECLARE(switch_call_cause_t) switch_channel_str2cause(const char *str)
{ {
uint8_t x; 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) { if (!zstr(str)) {
cause = atoi(str); if (*str > 47 && *str < 58) {
} else { cause = atoi(str);
for (x = 0; x < (sizeof(CAUSE_CHART) / sizeof(struct switch_cause_table)) - 1 && CAUSE_CHART[x].name; x++) { } else {
if (!strcasecmp(CAUSE_CHART[x].name, str)) { for (x = 0; x < (sizeof(CAUSE_CHART) / sizeof(struct switch_cause_table)) - 1 && CAUSE_CHART[x].name; x++) {
cause = CAUSE_CHART[x].cause; if (!strcasecmp(CAUSE_CHART[x].name, str)) {
break; cause = CAUSE_CHART[x].cause;
break;
}
} }
} }
} }
return cause; return cause;
} }