projects
/
paraslash.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4ca9b7b
)
tv_divide(): Check for division by zero
author
Andre Noll
<maan@congo.fml.local>
Wed, 23 Aug 2006 18:38:15 +0000
(20:38 +0200)
committer
Andre Noll
<maan@congo.fml.local>
Wed, 23 Aug 2006 18:38:15 +0000
(20:38 +0200)
time.c
patch
|
blob
|
history
diff --git
a/time.c
b/time.c
index
49b941b
..
83231c8
100644
(file)
--- 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;