shithub: openh264

Download patch

ref: a3f129d8cd3369b2e91ecdd69cdbe2e37bbe8192
parent: 3a602a382bb9d70bb8e22d58aaeefb7e2187a738
parent: b7db015a8cdbf4f265fc4d04f9fa9e56b283266c
author: volvet <qizh@cisco.com>
date: Mon Mar 3 04:05:27 EST 2014

Merge pull request #382 from mstorsjo/avoid-overflow-in-timespec

Avoid overflow when populating a struct timespec

--- a/codec/common/WelsThreadLib.cpp
+++ b/codec/common/WelsThreadLib.cpp
@@ -319,8 +319,9 @@
 
     gettimeofday (&tv, 0);
 
-    ts.tv_sec = tv.tv_sec + dwMilliseconds / 1000;
-    ts.tv_nsec = tv.tv_usec * 1000 + (dwMilliseconds % 1000) * 1000000;
+    ts.tv_nsec = tv.tv_usec * 1000 + dwMilliseconds * 1000000;
+    ts.tv_sec = tv.tv_sec + ts.tv_nsec / 1000000000;
+    ts.tv_nsec %= 1000000000;
 
     return sem_timedwait (event, &ts);
 #endif//__APPLE__