From 17754cea09a72217795406f2d0d335c69b707b82 Mon Sep 17 00:00:00 2001
From: Rob Pilling <rob@egbert>
Date: Wed, 19 Jun 2013 21:24:01 +0100
Subject: [PATCH] Fixed lock up when system time jumps backwards

---
 st.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/st.c b/st.c
index 2811876..02a3051 100644
--- a/st.c
+++ b/st.c
@@ -3540,6 +3540,8 @@ run(void) {
 	gettimeofday(&last, NULL);
 
 	for(xev = actionfps;;) {
+		long deltatime;
+
 		FD_ZERO(&rfd);
 		FD_SET(cmdfd, &rfd);
 		FD_SET(xfd, &rfd);
@@ -3573,8 +3575,9 @@ run(void) {
 			gettimeofday(&lastblink, NULL);
 			dodraw = 1;
 		}
-		if(TIMEDIFF(now, last) \
-				> (xev? (1000/xfps) : (1000/actionfps))) {
+		deltatime = TIMEDIFF(now, last);
+		if(deltatime > (xev? (1000/xfps) : (1000/actionfps))
+				|| deltatime < 0) {
 			dodraw = 1;
 			last = now;
 		}
-- 
1.7.10.4

