From: Markus Rathgeb Date: Mon, 16 Apr 2012 20:31:51 +0000 (+0200) Subject: Fix QMutex::tryLock timeout regression (integer overflow) X-Git-Tag: 071012110112~1444 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e998f971f6b7d05748b9478909c068605507d8f6;p=profile%2Fivi%2Fqtbase.git Fix QMutex::tryLock timeout regression (integer overflow) The timeout given in milliseconds should be converted to a timespec struct. To separate the seconds and nanoseconds the milliseconds are first multiplied to represent the whole value in an int64 variable. The calculation is done on integers, so we get an overflow if the milliseconds are bigger then 2148. If we cast the given value to an int64 we can avoid this problem. Fix the used cast. Task-number: QTBUG-24795 Change-Id: I864ae227cf7dda16a6f30aa4db74acc49e20f6eb Reviewed-by: Olivier Goffart Reviewed-by: Bradley T. Hughes --- diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index 1bb5e77..76e644a 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -121,7 +121,7 @@ bool QBasicMutex::lockInternal(int timeout) struct timespec ts, *pts = 0; if (timeout >= 1) { // recalculate the timeout - qint64 xtimeout = timeout * 1000 * 1000; + qint64 xtimeout = qint64(timeout) * 1000 * 1000; xtimeout -= elapsedTimer.nsecsElapsed(); if (xtimeout <= 0) { // timer expired after we returned