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
1 changed files with 7 additions and 1 deletions

View File

@ -365,11 +365,17 @@ fluid_is_soundfont(const char *filename)
*/
unsigned int fluid_curtime(void)
{
static glong initial_seconds = 0;
GTimeVal timeval;
if (initial_seconds == 0) {
g_get_current_time (&timeval);
initial_seconds = timeval.tv_sec;
}
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);
}
/**