Skip to contentSkip to conversation

verify SDL_Init

PATCH New Robert Millan 1 participant 1 message Sep 24, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 verify SDL_Init

Skipping SDL_Init failure leads to segfault in further SDL calls. This patch makes the situation easier to understand to the user.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)

Index: re.c
===================================================================
RCS file: /cvsroot/nouveau/renouveau/re.c,v
retrieving revision 1.125

re.c +4 -1
diff -u -r1.125 re.c
@@ -53,7 +53,10 @@
  */
 void setup_SDL(int opengl)
 {
-	SDL_Init(SDL_INIT_VIDEO);
+	if (SDL_Init(SDL_INIT_VIDEO)) {
+                fprintf (stderr, "Failed to initialise SDL video output.\n");
+                exit (1);
+        }
 	if (opengl) {
 		//SDL_GL_SetAttribute(SDL_GL_STEREO,1);
 		SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,0);

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau