From 823db4475c33673dca6a832a64cd836df9e42c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 5 Jul 2014 10:25:28 +0200 Subject: core: check that timeval arguments are not NULL in timeval functions --- src/core/wee-util.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') 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) -- cgit v1.2.3