Fix overflow in fluid_curtime(), reported and diagnosed by Felix Krause.

This commit is contained in:
Pedro Lopez-Cabanillas 2010-03-17 15:40:07 +00:00
parent 420882ce2e
commit 079e437330

View file

@ -365,11 +365,17 @@ fluid_is_soundfont(const char *filename)
*/ */
unsigned int fluid_curtime(void) unsigned int fluid_curtime(void)
{ {
static glong initial_seconds = 0;
GTimeVal timeval; GTimeVal timeval;
if (initial_seconds == 0) {
g_get_current_time (&timeval);
initial_seconds = timeval.tv_sec;
}
g_get_current_time (&timeval); g_get_current_time (&timeval);
return (timeval.tv_sec * 1000.0 + timeval.tv_usec / 1000.0); return (unsigned int)((timeval.tv_sec - initial_seconds) * 1000.0 + timeval.tv_usec / 1000.0);
} }
/** /**