Skip to content

Commit

Permalink
Added checks for NULL data sources to individual loaders.
Browse files Browse the repository at this point in the history
Apps shouldn't be calling them, but they do.  Naughty naughty! :)
  • Loading branch information
slouken committed Jan 4, 2004
1 parent c7a0893 commit b04e82b
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions IMG_jpg.c
Expand Up @@ -197,6 +197,11 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
SDL_Surface *volatile surface = NULL;
struct my_error_mgr jerr;

if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}

/* Create a decompression structure and load the JPEG header */
cinfo.err = jpeg_std_error(&jerr.errmgr);
jerr.errmgr.error_exit = my_error_exit;
Expand Down
4 changes: 4 additions & 0 deletions IMG_lbm.c
Expand Up @@ -94,6 +94,10 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
error = NULL;
MiniBuf = NULL;

if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}
if ( !SDL_RWread( src, id, 4, 1 ) )
{
error="error reading IFF chunk";
Expand Down
4 changes: 4 additions & 0 deletions IMG_pcx.c
Expand Up @@ -96,6 +96,10 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src)
char *error = NULL;
int bits, src_bits;

if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}
if ( ! SDL_RWread(src, &pcxh, sizeof(pcxh), 1) ) {
error = "file truncated";
goto done;
Expand Down
5 changes: 5 additions & 0 deletions IMG_png.c
Expand Up @@ -111,6 +111,11 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
volatile int ckey = -1;
png_color_16 *transv;

if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}

/* Initialize the data we will clean up when we're done */
png_ptr = NULL; info_ptr = NULL; row_pointers = NULL; surface = NULL;

Expand Down
5 changes: 5 additions & 0 deletions IMG_pnm.c
Expand Up @@ -108,6 +108,11 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src)

#define ERROR(s) do { error = (s); goto done; } while(0)

if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}

SDL_RWread(src, magic, 2, 1);
kind = magic[1] - '1';
ascii = 1;
Expand Down
5 changes: 5 additions & 0 deletions IMG_tga.c
Expand Up @@ -107,6 +107,11 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src)
Uint32 pixel;
int count, rep;

if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}

if(!SDL_RWread(src, &hdr, sizeof(hdr), 1))
goto error;
ncols = LE16(hdr.cmap_len);
Expand Down
4 changes: 4 additions & 0 deletions IMG_tif.c
Expand Up @@ -110,6 +110,10 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
Uint32 x, y;
Uint32 half;

if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}

/* turn off memory mapped access with the m flag */
tiff = TIFFClientOpen("SDL_image", "rm", (thandle_t)src,
Expand Down
5 changes: 5 additions & 0 deletions IMG_xcf.c
Expand Up @@ -678,6 +678,11 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) {

unsigned char * (* load_tile) (SDL_RWops *, Uint32, int, int, int);

if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}

/* Initialize the data we will clean up when we're done */
surface = NULL;
read_error = 0;
Expand Down
4 changes: 4 additions & 0 deletions IMG_xpm.c
Expand Up @@ -456,6 +456,10 @@ static SDL_Surface *load_xpm(char **xpm, SDL_RWops *src)
/* Load a XPM type image from an RWops datasource */
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
{
if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}
return load_xpm(NULL, src);
}

Expand Down
4 changes: 4 additions & 0 deletions IMG_xxx.c
Expand Up @@ -43,6 +43,10 @@ int IMG_isXXX(SDL_RWops *src)
/* Load a XXX type image from an SDL datasource */
SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src)
{
if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}
return(NULL);
}

Expand Down

0 comments on commit b04e82b

Please sign in to comment.