--- SDL_Perl-2.1.2/src/SDL_perl.xs	2005-10-02 17:33:28.000000000 +0200
+++ SDL_perl.xs	2006-05-23 20:30:23.000000000 +0200
@@ -3062,11 +3062,13 @@
 				dest.w = w;
 				dest.h = h;
 		}
-		if ( img && img->format && img->format->palette ) {
-			SDL_Color *c = &img->format->palette->colors[0];
-			Uint32 key = SDL_MapRGB( img->format, c->r, c->g, c->b );
-			SDL_SetColorKey(img,SDL_SRCCOLORKEY,key );
-			if (0 > SDL_BlitSurface(img,NULL,surface,&dest)) {
+		if ( img && img->format ) {
+                        if ( img->format->palette ) {
+                                SDL_Color *c = &img->format->palette->colors[0];
+                                Uint32 key = SDL_MapRGB( img->format, c->r, c->g, c->b );
+                                SDL_SetColorKey(img,SDL_SRCCOLORKEY,key );
+                        }
+                        if (0 > SDL_BlitSurface(img,NULL,surface,&dest)) {
 				SDL_FreeSurface(img);
 				RETVAL = NULL;	
 			} else {

