]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11981: [Core] Fix FreeSWITCH crash when timerfd is initialized with an error.
authorAndrey Volk <andywolk@gmail.com>
Mon, 19 Aug 2019 17:35:23 +0000 (21:35 +0400)
committerAndrey Volk <andywolk@gmail.com>
Mon, 19 Aug 2019 17:35:23 +0000 (21:35 +0400)
src/switch_time.c

index 46a3a087120c7cc9538a5fd3863d7b107c805a0b..cbb47f9ef7ade60eda814b743bb5fbeb434aee30 100644 (file)
@@ -479,6 +479,10 @@ static switch_status_t _timerfd_next(switch_timer_t *timer)
        interval_timer_t *it = timer->private_info;
        uint64_t u64  = 0;
 
+       if (!it) {
+               return SWITCH_STATUS_GENERR;
+       }
+
        if (read(it->fd, &u64, sizeof(u64)) < 0) {
                return SWITCH_STATUS_GENERR;
        } else {
@@ -495,6 +499,10 @@ static switch_status_t _timerfd_check(switch_timer_t *timer, switch_bool_t step)
        struct itimerspec val;
        int diff;
 
+       if (!it) {
+               return SWITCH_STATUS_GENERR;
+       }
+
        timerfd_gettime(it->fd, &val);
        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)
 static switch_status_t _timerfd_destroy(switch_timer_t *timer)
 {
        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;
 }