Skip to content

Commit

Permalink
timespec_add: fix an assertion failure
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jul 8, 2023
1 parent f748c82 commit 6fd4eb6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/timeutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ timespec_add(const struct timespec *a, const struct timespec *b,
* where time_t is signed
*/
c->tv_sec = (time_t)((uintmax_t)a->tv_sec + b->tv_sec + ovfl);
if (timespec_cmp(c, a) < 0) {
if (c->tv_sec < 0 || timespec_cmp(c, a) < 0) {
return EOVERFLOW;
}
assert_normalized(c);
Expand Down

0 comments on commit 6fd4eb6

Please sign in to comment.