提交 48b8fa58 authored 作者: Andrey Volk's avatar Andrey Volk

FS-11981: [Core] Fix FreeSWITCH crash when timerfd is initialized with an error.

上级 0ed24cfa
...@@ -479,6 +479,10 @@ static switch_status_t _timerfd_next(switch_timer_t *timer) ...@@ -479,6 +479,10 @@ static switch_status_t _timerfd_next(switch_timer_t *timer)
interval_timer_t *it = timer->private_info; interval_timer_t *it = timer->private_info;
uint64_t u64 = 0; uint64_t u64 = 0;
if (!it) {
return SWITCH_STATUS_GENERR;
}
if (read(it->fd, &u64, sizeof(u64)) < 0) { if (read(it->fd, &u64, sizeof(u64)) < 0) {
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} else { } else {
...@@ -495,6 +499,10 @@ static switch_status_t _timerfd_check(switch_timer_t *timer, switch_bool_t step) ...@@ -495,6 +499,10 @@ static switch_status_t _timerfd_check(switch_timer_t *timer, switch_bool_t step)
struct itimerspec val; struct itimerspec val;
int diff; int diff;
if (!it) {
return SWITCH_STATUS_GENERR;
}
timerfd_gettime(it->fd, &val); timerfd_gettime(it->fd, &val);
diff = val.it_interval.tv_nsec / 1000; diff = val.it_interval.tv_nsec / 1000;
...@@ -515,9 +523,12 @@ static switch_status_t _timerfd_check(switch_timer_t *timer, switch_bool_t step) ...@@ -515,9 +523,12 @@ static switch_status_t _timerfd_check(switch_timer_t *timer, switch_bool_t step)
static switch_status_t _timerfd_destroy(switch_timer_t *timer) static switch_status_t _timerfd_destroy(switch_timer_t *timer)
{ {
interval_timer_t *it = timer->private_info; interval_timer_t *it = timer->private_info;
int rc; int rc = SWITCH_STATUS_GENERR;
if (it) {
rc = timerfd_stop_interval(it);
}
rc = timerfd_stop_interval(it);
return rc; return rc;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论