summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-util.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index 9d93c396b..1223b0488 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -237,6 +237,9 @@ util_setrlimit ()
int
util_timeval_cmp (struct timeval *tv1, struct timeval *tv2)
{
+ if (!tv1 || !tv2)
+ return (tv1) ? 1 : ((tv2) ? -1 : 0);
+
if (tv1->tv_sec < tv2->tv_sec)
return -1;
if (tv1->tv_sec > tv2->tv_sec)
@@ -259,6 +262,9 @@ util_timeval_diff (struct timeval *tv1, struct timeval *tv2)
{
long diff_sec, diff_usec;
+ if (!tv1 || !tv2)
+ return 0;
+
diff_sec = tv2->tv_sec - tv1->tv_sec;
diff_usec = tv2->tv_usec - tv1->tv_usec;
@@ -279,6 +285,9 @@ util_timeval_add (struct timeval *tv, long interval)
{
long usec;
+ if (!tv)
+ return;
+
tv->tv_sec += (interval / 1000);
usec = tv->tv_usec + ((interval % 1000) * 1000);
if (usec > 1000000)