From 6e2e2739acdbacb5f0d4b4272b0e04f74184c66a Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 23 Aug 2006 20:38:15 +0200 Subject: [PATCH] tv_divide(): Check for division by zero --- time.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/time.c b/time.c index 49b941bb..83231c89 100644 --- a/time.c +++ b/time.c @@ -113,7 +113,13 @@ void tv_scale(const unsigned long mult, const struct timeval *tv, void tv_divide(const unsigned long divisor, const struct timeval *tv, struct timeval *result) { - long unsigned q = tv->tv_usec / divisor; + long unsigned q; + + if (!divisor) { + PARA_EMERG_LOG("%s\n", "division by zero"); + exit(EXIT_FAILURE); + } + q = tv->tv_usec / divisor; result->tv_sec = tv->tv_sec / divisor; result->tv_usec = (tv->tv_sec - result->tv_sec * divisor) * 1000 * 1000 / divisor; -- 2.39.2