diff -u sdl-image1.2-1.2.5/IMG_bmp.c sdl-image1.2-marga/IMG_bmp.c
--- sdl-image1.2-1.2.5/IMG_bmp.c	2006-05-14 17:57:03.000000000 -0300
+++ sdl-image1.2-marga/IMG_bmp.c	2006-07-21 20:34:29.193015440 -0300
@@ -36,6 +36,8 @@
 	int is_BMP;
 	char magic[2];
 
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_BMP = 0;
 	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
diff -u sdl-image1.2-1.2.5/IMG_gif.c sdl-image1.2-marga/IMG_gif.c
--- sdl-image1.2-1.2.5/IMG_gif.c	2006-05-14 16:54:24.000000000 -0300
+++ sdl-image1.2-marga/IMG_gif.c	2006-07-21 20:33:22.437423410 -0300
@@ -36,6 +36,8 @@
 	int is_GIF;
 	char magic[6];
 
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_GIF = 0;
 	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
diff -u sdl-image1.2-1.2.5/IMG_jpg.c sdl-image1.2-marga/IMG_jpg.c
--- sdl-image1.2-1.2.5/IMG_jpg.c	2006-05-14 16:54:24.000000000 -0300
+++ sdl-image1.2-marga/IMG_jpg.c	2006-07-21 20:22:29.386350188 -0300
@@ -179,6 +179,8 @@
 	/* Blame me, not Sam, if this doesn't work right. */
 	/* And don't forget to report the problem to the the sdl list too! */
 
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_JPG = 0;
 	in_scan = 0;
diff -u sdl-image1.2-1.2.5/IMG_lbm.c sdl-image1.2-marga/IMG_lbm.c
--- sdl-image1.2-1.2.5/IMG_lbm.c	2006-05-12 00:02:44.000000000 -0300
+++ sdl-image1.2-marga/IMG_lbm.c	2006-07-21 20:33:14.278818049 -0300
@@ -65,6 +65,8 @@
 	int   is_LBM;
 	Uint8 magic[4+4+4];
 
+	if ( !src ) 
+		return 0;
 	start = SDL_RWtell(src);
 	is_LBM = 0;
 	if ( SDL_RWread( src, magic, sizeof(magic), 1 ) )
diff -u sdl-image1.2-1.2.5/IMG_pcx.c sdl-image1.2-marga/IMG_pcx.c
--- sdl-image1.2-1.2.5/IMG_pcx.c	2006-05-01 04:25:51.000000000 -0300
+++ sdl-image1.2-marga/IMG_pcx.c	2006-07-21 20:25:15.919749204 -0300
@@ -69,6 +69,8 @@
 	const int PCX_RunLength_Encoding = 1;
 	struct PCXheader pcxh;
 
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_PCX = 0;
 	if ( SDL_RWread(src, &pcxh, sizeof(pcxh), 1) == 1 ) {
diff -u sdl-image1.2-1.2.5/IMG_png.c sdl-image1.2-marga/IMG_png.c
--- sdl-image1.2-1.2.5/IMG_png.c	2006-05-14 16:54:24.000000000 -0300
+++ sdl-image1.2-marga/IMG_png.c	2006-07-21 20:25:07.367217023 -0300
@@ -273,6 +273,8 @@
 	if ( IMG_InitPNG() < 0 ) {
 		return 0;
 	}
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_PNG = 0;
 	if ( SDL_RWread(src, buf, 1, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK ) {
diff -u sdl-image1.2-1.2.5/IMG_pnm.c sdl-image1.2-marga/IMG_pnm.c
--- sdl-image1.2-1.2.5/IMG_pnm.c	2006-05-01 04:25:51.000000000 -0300
+++ sdl-image1.2-marga/IMG_pnm.c	2006-07-21 20:26:06.881005273 -0300
@@ -44,6 +44,8 @@
 	int is_PNM;
 	char magic[2];
 
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_PNM = 0;
 	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
diff -u sdl-image1.2-1.2.5/IMG_tif.c sdl-image1.2-marga/IMG_tif.c
--- sdl-image1.2-1.2.5/IMG_tif.c	2006-07-21 20:31:17.000000000 -0300
+++ sdl-image1.2-marga/IMG_tif.c	2006-07-21 20:27:09.959187601 -0300
@@ -189,6 +189,8 @@
 	if ( IMG_InitTIF() < 0 ) {
 		return 0;
 	}
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_TIF = 0;
 
diff -u sdl-image1.2-1.2.5/IMG_xcf.c sdl-image1.2-marga/IMG_xcf.c
--- sdl-image1.2-1.2.5/IMG_xcf.c	2006-05-01 04:25:51.000000000 -0300
+++ sdl-image1.2-marga/IMG_xcf.c	2006-07-21 20:28:49.113194657 -0300
@@ -213,6 +213,8 @@
 	int is_XCF;
 	char magic[14];
 
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_XCF = 0;
 	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
diff -u sdl-image1.2-1.2.5/IMG_xpm.c sdl-image1.2-marga/IMG_xpm.c
--- sdl-image1.2-1.2.5/IMG_xpm.c	2006-05-12 00:02:44.000000000 -0300
+++ sdl-image1.2-marga/IMG_xpm.c	2006-07-21 20:33:29.517213256 -0300
@@ -59,6 +59,8 @@
 	int is_XPM;
 	char magic[9];
 
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_XPM = 0;
 	if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
@@ -326,7 +328,8 @@
 	linebuf = NULL;
 	buflen = 0;
 
-	start = SDL_RWtell(src);
+	if ( src ) 
+		start = SDL_RWtell(src);
 
 	if(xpm)
 		xpmlines = &xpm;
@@ -453,7 +456,8 @@
 
 done:
 	if(error) {
-		SDL_RWseek(src, start, SEEK_SET);
+		if ( src )
+			SDL_RWseek(src, start, SEEK_SET);
 		if ( image ) {
 			SDL_FreeSurface(image);
 			image = NULL;
diff -u sdl-image1.2-1.2.5/IMG_xv.c sdl-image1.2-marga/IMG_xv.c
--- sdl-image1.2-1.2.5/IMG_xv.c	2006-05-01 04:25:51.000000000 -0300
+++ sdl-image1.2-marga/IMG_xv.c	2006-07-21 20:29:16.504502815 -0300
@@ -89,6 +89,8 @@
 	int is_XV;
 	int w, h;
 
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_XV = 0;
 	if ( get_header(src, &w, &h) == 0 ) {
diff -u sdl-image1.2-1.2.5/IMG_xxx.c sdl-image1.2-marga/IMG_xxx.c
--- sdl-image1.2-1.2.5/IMG_xxx.c	2006-05-01 04:25:51.000000000 -0300
+++ sdl-image1.2-marga/IMG_xxx.c	2006-07-21 20:29:57.169539262 -0300
@@ -34,6 +34,8 @@
 	int start;
 	int is_XXX;
 
+	if ( !src )
+		return 0;
 	start = SDL_RWtell(src);
 	is_XXX = 0;
 

