timer: fix integer overflow in timer_delay()

Fixes a regression: for output_plugin.delay(), we added a method to
the timer class which returns the delay in milliseconds.  This fails
to detect negative values, because the unsigned integer is divided by
1000, and then casted to signed.
This commit is contained in:
Max Kellermann 2010-11-18 21:29:03 +01:00
parent 46ab8d18e2
commit 8f46f1520c

View File

@ -74,7 +74,7 @@ void timer_add(Timer *timer, int size)
unsigned
timer_delay(const Timer *timer)
{
int64_t delay = (timer->time - now()) / 1000;
int64_t delay = (int64_t)(timer->time - now()) / 1000;
if (delay < 0)
return 0;