From 0f62cd83a799fb04f0ffabf59f8b4653b789cdc7 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Wed, 24 Sep 2008 01:18:59 +0000
Subject: [PATCH] Work around possible NULL dereference if the mode is not
 initialized within .5 seconds of initialization.  This may fix the reported
 crashes on OS X at startup using SDL mode.

---
 src/conio/bitmap_con.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c
index 04cfc13cfb..8d2547504c 100644
--- a/src/conio/bitmap_con.c
+++ b/src/conio/bitmap_con.c
@@ -25,7 +25,7 @@
 #include "allfonts.h"
 #include "bitmap_con.h"
 
-static char *screen;
+static char *screen=NULL;
 int screenwidth;
 int screenheight;
 #define PIXEL_OFFSET(x,y)	( (y)*screenwidth+(x) )
@@ -62,7 +62,9 @@ static void blinker_thread(void *data)
 	int count=0;
 
 	while(1) {
-		SLEEP(10);
+		do {
+			SLEEP(10);
+		} while(screen==NULL);
 		count++;
 		pthread_mutex_lock(&vstatlock);
 		if(count==50) {
-- 
GitLab