Skip to content

Commit e021d6e

Browse files
authored
Merge pull request tree-sitter#1990 from DeepChannel/fix/nanos-rollover
fix: possible rollover of nanoseconds in clock.h
2 parents 6f42c78 + eb549a8 commit e021d6e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/src/clock.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ static inline TSClock clock_after(TSClock base, TSDuration duration) {
8282
TSClock result = base;
8383
result.tv_sec += duration / 1000000;
8484
result.tv_nsec += (duration % 1000000) * 1000;
85+
if (result.tv_nsec >= 1000000000) {
86+
result.tv_nsec -= 1000000000;
87+
++(result.tv_sec);
88+
}
8589
return result;
8690
}
8791

0 commit comments

Comments
 (0)