check for NULL

next_timeout can be NULL if there are no timeouts
fixes #20