Commit 81df45be authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_cond_timedwait: fix unlikely Win32 DWORD overflow

parent b09d329b
...@@ -386,14 +386,19 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line, ...@@ -386,14 +386,19 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
(void)psz_file; (void)i_line; (void)psz_file; (void)i_line;
#elif defined( WIN32 ) #elif defined( WIN32 )
mtime_t delay_ms = (deadline - mdate())/1000; mtime_t total = (deadline - mdate())/1000;
DWORD result; DWORD result;
if( delay_ms < 0 ) if( total < 0 )
delay_ms = 0; total = 0;
/* Increase our wait count */ do
result = SignalObjectAndWait( *p_mutex, *p_condvar, {
delay_ms, FALSE ); DWORD delay = (total > 0x7fffffff) ? 0x7fffffff : total;
result = SignalObjectAndWait( *p_mutex, *p_condvar,
delay, FALSE );
total -= delay;
}
while (total);
/* Reacquire the mutex before returning. */ /* Reacquire the mutex before returning. */
vlc_mutex_lock( p_mutex ); vlc_mutex_lock( p_mutex );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment