[vlc-devel] commit: vlc_cond_timedwait: fix unlikely Win32 DWORD overflow ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Aug 10 14:10:20 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Aug 10 15:12:41 2008 +0300| [81df45be607d2fd9078d2896794ed0f4edef3f52] | committer: Rémi Denis-Courmont 

vlc_cond_timedwait: fix unlikely Win32 DWORD overflow

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=81df45be607d2fd9078d2896794ed0f4edef3f52
---

 include/vlc_threads.h |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 376703d..675a8ea 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -386,14 +386,19 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
     (void)psz_file; (void)i_line;
 
 #elif defined( WIN32 )
-    mtime_t delay_ms = (deadline - mdate())/1000;
+    mtime_t total = (deadline - mdate())/1000;
     DWORD result;
-    if( delay_ms < 0 )
-        delay_ms = 0;
+    if( total < 0 )
+        total = 0;
 
-    /* Increase our wait count */
-    result = SignalObjectAndWait( *p_mutex, *p_condvar,
-                                  delay_ms, FALSE );
+    do
+    {
+        DWORD delay = (total > 0x7fffffff) ? 0x7fffffff : total;
+        result = SignalObjectAndWait( *p_mutex, *p_condvar,
+                                      delay, FALSE );
+        total -= delay;
+    }
+    while (total);
 
     /* Reacquire the mutex before returning. */
     vlc_mutex_lock( p_mutex );




More information about the vlc-devel mailing list