diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-07-05 10:25:28 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-07-05 10:25:28 +0200 |
commit | 823db4475c33673dca6a832a64cd836df9e42c52 (patch) | |
tree | f6d54a237dff678a5a7dc18da37fa61f2c7bf26f /src | |
parent | e0e3f9fdeecc438489c06eb72e7afe91de3c7102 (diff) | |
download | weechat-823db4475c33673dca6a832a64cd836df9e42c52.zip |
core: check that timeval arguments are not NULL in timeval functions
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-util.c | 9 |
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) |