Merge branch 'mbedtls-2.1' into mbedtls-2.1-restricted
diff --git a/ChangeLog b/ChangeLog
index 2802fe9..c718992 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -94,7 +94,7 @@
fragile yet non-exploitable code-paths.
* Fix crash when calling mbedtls_ssl_cache_free() twice. Found by
MilenkoMitrovic, #1104
- * Fix mbedtls_timing_alarm(0) on Unix.
+ * Fix mbedtls_timing_alarm(0) on Unix and MinGw.
* Fix use of uninitialized memory in mbedtls_timing_get_timer when reset=1.
* Fix issue in RSA key generation program programs/x509/rsa_genkey
where the failure of CTR DRBG initialization lead to freeing an
diff --git a/library/timing.c b/library/timing.c
index de936e1..d9db5d2 100644
--- a/library/timing.c
+++ b/library/timing.c
@@ -273,6 +273,14 @@
{
DWORD ThreadId;
+ if( seconds == 0 )
+ {
+ /* No need to create a thread for this simple case.
+ * Also, this shorcut is more reliable at least on MinGW32 */
+ mbedtls_timing_alarmed = 1;
+ return;
+ }
+
mbedtls_timing_alarmed = 0;
alarmMs = seconds * 1000;
CloseHandle( CreateThread( NULL, 0, TimerProc, NULL, 0, &ThreadId ) );