Fixed bug 1979 - X11_SetGammaRamp doesn't check the return value of XStoreColors SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Sun, 21 Jul 2013 11:09:53 -0700
branchSDL-1.2
changeset 7491 3665bc284271
parent 7411 14827e7e4d92
child 7625 952791dbe6ba
Fixed bug 1979 - X11_SetGammaRamp doesn't check the return value of XStoreColors Sven Hesse Here on my laptop with an ATI Mobility Radeon 9600 PRO Turbo (RV350), the free radeon drivers and X.org 1.12.4, SDL_SetGamma() fails because it tries to use SDL_SetGammaRamp() if available. SDL_SetGammaRamp() uses XStoreColors(), and that call always fails with BadRequest (for whatever reason, I don't know). The SDL_Visual class check goes through, though. Now, XStoreColors failing is maybe another bug in SDL, or in Xorg, or in the radeon drivers or anywhere else, but I think SDL should still check that the XStoreColors() doesn't error as well.
src/video/x11/SDL_x11video.c
--- a/src/video/x11/SDL_x11video.c	Fri Jul 12 01:39:18 2013 -0400
+++ b/src/video/x11/SDL_x11video.c	Sun Jul 21 11:09:53 2013 -0700
@@ -1481,7 +1481,10 @@
 		xcmap[i].blue  = ramp[2*256+c];
 		xcmap[i].flags = (DoRed|DoGreen|DoBlue);
 	}
-	XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
+	if ( XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors) != 0 ) {
+		SDL_SetError("Setting gamma correction failed");
+		return(-1);
+	}
 	XSync(GFX_Display, False);
 	return(0);
 }