Added checks for NULL data sources to individual loaders.
authorSam Lantinga <slouken@libsdl.org>
Sun, 04 Jan 2004 22:04:38 +0000
changeset 989f94c4674cc9
parent 97 e1161bd417c4
child 99 9256da39d67e
Added checks for NULL data sources to individual loaders.
Apps shouldn't be calling them, but they do. Naughty naughty! :)
IMG_jpg.c
IMG_lbm.c
IMG_pcx.c
IMG_png.c
IMG_pnm.c
IMG_tga.c
IMG_tif.c
IMG_xcf.c
IMG_xpm.c
IMG_xxx.c
     1.1 --- a/IMG_jpg.c	Sun Jan 04 17:41:55 2004 +0000
     1.2 +++ b/IMG_jpg.c	Sun Jan 04 22:04:38 2004 +0000
     1.3 @@ -197,6 +197,11 @@
     1.4  	SDL_Surface *volatile surface = NULL;
     1.5  	struct my_error_mgr jerr;
     1.6  
     1.7 +	if ( !src ) {
     1.8 +		/* The error message has been set in SDL_RWFromFile */
     1.9 +		return NULL;
    1.10 +	}
    1.11 +
    1.12  	/* Create a decompression structure and load the JPEG header */
    1.13  	cinfo.err = jpeg_std_error(&jerr.errmgr);
    1.14  	jerr.errmgr.error_exit = my_error_exit;
     2.1 --- a/IMG_lbm.c	Sun Jan 04 17:41:55 2004 +0000
     2.2 +++ b/IMG_lbm.c	Sun Jan 04 22:04:38 2004 +0000
     2.3 @@ -94,6 +94,10 @@
     2.4  	error   = NULL;
     2.5  	MiniBuf = NULL;
     2.6  
     2.7 +	if ( !src ) {
     2.8 +		/* The error message has been set in SDL_RWFromFile */
     2.9 +		return NULL;
    2.10 +	}
    2.11  	if ( !SDL_RWread( src, id, 4, 1 ) )
    2.12  	{
    2.13  		error="error reading IFF chunk";
     3.1 --- a/IMG_pcx.c	Sun Jan 04 17:41:55 2004 +0000
     3.2 +++ b/IMG_pcx.c	Sun Jan 04 22:04:38 2004 +0000
     3.3 @@ -96,6 +96,10 @@
     3.4  	char *error = NULL;
     3.5  	int bits, src_bits;
     3.6  
     3.7 +	if ( !src ) {
     3.8 +		/* The error message has been set in SDL_RWFromFile */
     3.9 +		return NULL;
    3.10 +	}
    3.11  	if ( ! SDL_RWread(src, &pcxh, sizeof(pcxh), 1) ) {
    3.12  		error = "file truncated";
    3.13  		goto done;
     4.1 --- a/IMG_png.c	Sun Jan 04 17:41:55 2004 +0000
     4.2 +++ b/IMG_png.c	Sun Jan 04 22:04:38 2004 +0000
     4.3 @@ -111,6 +111,11 @@
     4.4  	volatile int ckey = -1;
     4.5  	png_color_16 *transv;
     4.6  
     4.7 +	if ( !src ) {
     4.8 +		/* The error message has been set in SDL_RWFromFile */
     4.9 +		return NULL;
    4.10 +	}
    4.11 +
    4.12  	/* Initialize the data we will clean up when we're done */
    4.13  	png_ptr = NULL; info_ptr = NULL; row_pointers = NULL; surface = NULL;
    4.14  
     5.1 --- a/IMG_pnm.c	Sun Jan 04 17:41:55 2004 +0000
     5.2 +++ b/IMG_pnm.c	Sun Jan 04 22:04:38 2004 +0000
     5.3 @@ -108,6 +108,11 @@
     5.4  
     5.5  #define ERROR(s) do { error = (s); goto done; } while(0)
     5.6  
     5.7 +	if ( !src ) {
     5.8 +		/* The error message has been set in SDL_RWFromFile */
     5.9 +		return NULL;
    5.10 +	}
    5.11 +
    5.12  	SDL_RWread(src, magic, 2, 1);
    5.13  	kind = magic[1] - '1';
    5.14  	ascii = 1;
     6.1 --- a/IMG_tga.c	Sun Jan 04 17:41:55 2004 +0000
     6.2 +++ b/IMG_tga.c	Sun Jan 04 22:04:38 2004 +0000
     6.3 @@ -107,6 +107,11 @@
     6.4      Uint32 pixel;
     6.5      int count, rep;
     6.6  
     6.7 +    if ( !src ) {
     6.8 +        /* The error message has been set in SDL_RWFromFile */
     6.9 +        return NULL;
    6.10 +    }
    6.11 +
    6.12      if(!SDL_RWread(src, &hdr, sizeof(hdr), 1))
    6.13  	goto error;
    6.14      ncols = LE16(hdr.cmap_len);
     7.1 --- a/IMG_tif.c	Sun Jan 04 17:41:55 2004 +0000
     7.2 +++ b/IMG_tif.c	Sun Jan 04 22:04:38 2004 +0000
     7.3 @@ -110,6 +110,10 @@
     7.4  	Uint32 x, y;
     7.5  	Uint32 half;
     7.6  
     7.7 +	if ( !src ) {
     7.8 +		/* The error message has been set in SDL_RWFromFile */
     7.9 +		return NULL;
    7.10 +	}
    7.11  
    7.12  	/* turn off memory mapped access with the m flag */
    7.13  	tiff = TIFFClientOpen("SDL_image", "rm", (thandle_t)src, 
     8.1 --- a/IMG_xcf.c	Sun Jan 04 17:41:55 2004 +0000
     8.2 +++ b/IMG_xcf.c	Sun Jan 04 22:04:38 2004 +0000
     8.3 @@ -678,6 +678,11 @@
     8.4  
     8.5    unsigned char * (* load_tile) (SDL_RWops *, Uint32, int, int, int);
     8.6  
     8.7 +  if ( !src ) {
     8.8 +    /* The error message has been set in SDL_RWFromFile */
     8.9 +    return NULL;
    8.10 +  }
    8.11 +
    8.12    /* Initialize the data we will clean up when we're done */
    8.13    surface = NULL;
    8.14    read_error = 0;
     9.1 --- a/IMG_xpm.c	Sun Jan 04 17:41:55 2004 +0000
     9.2 +++ b/IMG_xpm.c	Sun Jan 04 22:04:38 2004 +0000
     9.3 @@ -456,6 +456,10 @@
     9.4  /* Load a XPM type image from an RWops datasource */
     9.5  SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
     9.6  {
     9.7 +	if ( !src ) {
     9.8 +		/* The error message has been set in SDL_RWFromFile */
     9.9 +		return NULL;
    9.10 +	}
    9.11  	return load_xpm(NULL, src);
    9.12  }
    9.13  
    10.1 --- a/IMG_xxx.c	Sun Jan 04 17:41:55 2004 +0000
    10.2 +++ b/IMG_xxx.c	Sun Jan 04 22:04:38 2004 +0000
    10.3 @@ -43,6 +43,10 @@
    10.4  /* Load a XXX type image from an SDL datasource */
    10.5  SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src)
    10.6  {
    10.7 +	if ( !src ) {
    10.8 +		/* The error message has been set in SDL_RWFromFile */
    10.9 +		return NULL;
   10.10 +	}
   10.11  	return(NULL);
   10.12  }
   10.13