History

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

Avoid overflow when populating a struct timespec

volvet committed 12 years ago

Commit a3f129d2 parents 3a602a3 b7db0151 file · +3 −2Browse files

Showing the changes to codec/common/WelsThreadLib.cpp (1 of 1 file). Show all

Unified · Split

codec/common/WelsThreadLib.cpp+3−2
@@ -319,8 +319,9 @@ WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t · 318 unmodified lines
319319
320320 gettimeofday (&tv, 0);
321321
322− ts.tv_sec = tv.tv_sec + dwMilliseconds / 1000;
323− ts.tv_nsec = tv.tv_usec * 1000 + (dwMilliseconds % 1000) * 1000000;
322+ ts.tv_nsec = tv.tv_usec * 1000 + dwMilliseconds * 1000000;
323+ ts.tv_sec = tv.tv_sec + ts.tv_nsec / 1000000000;
324+ ts.tv_nsec %= 1000000000;
324325
325326 return sem_timedwait (event, &ts);
326327 #endif//__APPLE__

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t