Date: Fri, 19 Dec 2003 18:47:46 +0200
authorSam Lantinga <slouken@libsdl.org>
Fri, 19 Dec 2003 18:04:48 +0000
changeset 957fcb46931afc
parent 94 88ddfd74ad67
child 96 cada40fddd77
Date: Fri, 19 Dec 2003 18:47:46 +0200
From: "Mike Gorchak"
Subject: SDL image

I've fixed NULL pointer pass as RWops argument in all calls in the SDL_Image library, found that when porting toppler game to QNX6, they're do not checking any return pointers and then game failed in the SDL_image library internals, instead of fail in the toppler internals ;) And I've fixed the QNX6 .qpg file for automative package building.
IMG.c
IMG_lbm.c
IMG_pcx.c
IMG_png.c
IMG_pnm.c
IMG_xcf.c
SDL_image.qpg.in
     1.1 --- a/IMG.c	Wed Nov 19 08:20:27 2003 +0000
     1.2 +++ b/IMG.c	Fri Dec 19 18:04:48 2003 +0000
     1.3 @@ -39,7 +39,7 @@
     1.4  	SDL_Surface *(*load)(SDL_RWops *src);
     1.5  } supported[] = {
     1.6  	/* keep magicless formats first */
     1.7 -	{ "TGA", 0,         IMG_LoadTGA_RW },
     1.8 +	{ "TGA", NULL,      IMG_LoadTGA_RW },
     1.9  	{ "BMP", IMG_isBMP, IMG_LoadBMP_RW },
    1.10  	{ "PNM", IMG_isPNM, IMG_LoadPNM_RW }, /* P[BGP]M share code */
    1.11  	{ "XPM", IMG_isXPM, IMG_LoadXPM_RW },
    1.12 @@ -64,8 +64,13 @@
    1.13  {
    1.14      SDL_RWops *src = SDL_RWFromFile(file, "rb");
    1.15      char *ext = strrchr(file, '.');
    1.16 -    if(ext)
    1.17 -	ext++;
    1.18 +    if(ext) {
    1.19 +        ext++;
    1.20 +    }
    1.21 +    if(!src) {
    1.22 +        /* The error message has been set in SDL_RWFromFile */
    1.23 +        return NULL;
    1.24 +    }
    1.25      return IMG_LoadTyped_RW(src, 1, ext);
    1.26  }
    1.27  
    1.28 @@ -96,6 +101,7 @@
    1.29  
    1.30  	/* Make sure there is something to do.. */
    1.31  	if ( src == NULL ) {
    1.32 +		IMG_SetError("Passed a NULL data source");
    1.33  		return(NULL);
    1.34  	}
    1.35  
     2.1 --- a/IMG_lbm.c	Wed Nov 19 08:20:27 2003 +0000
     2.2 +++ b/IMG_lbm.c	Fri Dec 19 18:04:48 2003 +0000
     2.3 @@ -91,8 +91,6 @@
     2.4  	error   = NULL;
     2.5  	MiniBuf = NULL;
     2.6  
     2.7 -	if ( src == NULL ) goto done;
     2.8 -
     2.9  	if ( !SDL_RWread( src, id, 4, 1 ) ) 
    2.10  	{
    2.11  		error="error reading IFF chunk";
     3.1 --- a/IMG_pcx.c	Wed Nov 19 08:20:27 2003 +0000
     3.2 +++ b/IMG_pcx.c	Fri Dec 19 18:04:48 2003 +0000
     3.3 @@ -96,10 +96,6 @@
     3.4  	char *error = NULL;
     3.5  	int bits, src_bits;
     3.6  
     3.7 -	if ( ! src ) {
     3.8 -		goto done;
     3.9 -	}
    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	Wed Nov 19 08:20:27 2003 +0000
     4.2 +++ b/IMG_png.c	Fri Dec 19 18:04:48 2003 +0000
     4.3 @@ -114,11 +114,6 @@
     4.4  	/* Initialize the data we will clean up when we're done */
     4.5  	png_ptr = NULL; info_ptr = NULL; row_pointers = NULL; surface = NULL;
     4.6  
     4.7 -	/* Check to make sure we have something to do */
     4.8 -	if ( ! src ) {
     4.9 -		goto done;
    4.10 -	}
    4.11 -
    4.12  	/* Create the PNG loading context structure */
    4.13  	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
    4.14  					  NULL,NULL,NULL);
     5.1 --- a/IMG_pnm.c	Wed Nov 19 08:20:27 2003 +0000
     5.2 +++ b/IMG_pnm.c	Fri Dec 19 18:04:48 2003 +0000
     5.3 @@ -108,9 +108,6 @@
     5.4  
     5.5  #define ERROR(s) do { error = (s); goto done; } while(0)
     5.6  
     5.7 -	if(!src)
     5.8 -		return NULL;
     5.9 -
    5.10  	SDL_RWread(src, magic, 2, 1);
    5.11  	kind = magic[1] - '1';
    5.12  	ascii = 1;
     6.1 --- a/IMG_xcf.c	Wed Nov 19 08:20:27 2003 +0000
     6.2 +++ b/IMG_xcf.c	Fri Dec 19 18:04:48 2003 +0000
     6.3 @@ -678,11 +678,6 @@
     6.4  
     6.5    unsigned char * (* load_tile) (SDL_RWops *, Uint32, int, int, int);
     6.6  
     6.7 -  /* Check to make sure we have something to do */
     6.8 -  if ( ! src ) {
     6.9 -    return NULL;
    6.10 -  }
    6.11 -
    6.12    /* Initialize the data we will clean up when we're done */
    6.13    surface = NULL;
    6.14    read_error = 0;
     7.1 --- a/SDL_image.qpg.in	Wed Nov 19 08:20:27 2003 +0000
     7.2 +++ b/SDL_image.qpg.in	Fri Dec 19 18:04:48 2003 +0000
     7.3 @@ -37,6 +37,7 @@
     7.4        </QPG:Files>
     7.5        <QPG:PackageFilter>
     7.6           <QPM:PackageManifest>
     7.7 +
     7.8              <QPM:PackageDescription>
     7.9                 <QPM:PackageType>Library</QPM:PackageType>
    7.10                 <QPM:PackageName>SDL_image</QPM:PackageName>
    7.11 @@ -44,6 +45,7 @@
    7.12                 <QPM:PackageRepository>http://qnx.org.ru/repository</QPM:PackageRepository>
    7.13                 <QPM:FileVersion>2.0</QPM:FileVersion>
    7.14              </QPM:PackageDescription>
    7.15 +
    7.16              <QPM:ProductDescription>
    7.17                 <QPM:ProductName>SDL_image</QPM:ProductName>
    7.18                 <QPM:ProductIdentifier>SDL_image</QPM:ProductIdentifier>
    7.19 @@ -61,9 +63,10 @@
    7.20                 <QPM:ProductIconLarge/>
    7.21                 <QPM:ProductDescriptionShort>This is a simple library to load images of various formats as SDL surfaces. This library supports BMP, PPM, PCX, GIF, JPEG, PNG, and TIFF formats.</QPM:ProductDescriptionShort>
    7.22                 <QPM:ProductDescriptionLong>This is a simple library to load images of various formats as SDL surfaces. This library supports BMP, PPM, PCX, GIF, JPEG, PNG, and TIFF formats.</QPM:ProductDescriptionLong>
    7.23 -               <QPM:ProductDescriptionURL>http://www.libsdl.org</QPM:ProductDescriptionURL>
    7.24 +               <QPM:ProductDescriptionURL>http://www.libsdl.org/projects/SDL_image</QPM:ProductDescriptionURL>
    7.25                 <QPM:ProductDescriptionEmbedURL/>
    7.26              </QPM:ProductDescription>
    7.27 +
    7.28              <QPM:ReleaseDescription>
    7.29                 <QPM:ReleaseVersion>@VERSION@</QPM:ReleaseVersion>
    7.30                 <QPM:ReleaseUrgency>High</QPM:ReleaseUrgency>
    7.31 @@ -74,23 +77,52 @@
    7.32                 <QPM:CountryExclude/>
    7.33                 <QPM:ReleaseCopyright>GNU General Public License</QPM:ReleaseCopyright>
    7.34              </QPM:ReleaseDescription>
    7.35 +
    7.36              <QPM:ContentDescription>
    7.37 -               <QPM:ContentTopic>Software Development/Libraries and Extensions/C Libraries</QPM:ContentTopic>
    7.38 +               <QPM:ContentTopic xmlmultiple="true">Software Development/Libraries and Extensions/C Libraries</QPM:ContentTopic>
    7.39                 <QPM:ContentKeyword>SDL, graphics, images, BMP, PPM, PCX, GIF, JPEG, PNG, TIFF</QPM:ContentKeyword>
    7.40 -               <QPM:Processor/>
    7.41 -               <QPM:TargetProcessor/>
    7.42                 <QPM:TargetOS>qnx6</QPM:TargetOS>
    7.43 -               <QPM:HostOS>qnx6</QPM:HostOS>
    7.44 -               <QPM:DisplayEnvironment>Photon</QPM:DisplayEnvironment>
    7.45 -               <QPM:TargetAudience>Developer</QPM:TargetAudience>
    7.46 -               <QPM:TargetAudience>User</QPM:TargetAudience>
    7.47 +               <QPM:HostOS>none</QPM:HostOS>
    7.48 +               <QPM:DisplayEnvironment xmlmultiple="true">Photon</QPM:DisplayEnvironment>
    7.49 +               <QPM:DisplayEnvironment xmlmultiple="true">Console</QPM:DisplayEnvironment>
    7.50 +               <QPM:TargetAudience xmlmultiple="true">Developer</QPM:TargetAudience>
    7.51 +               <QPM:TargetAudience xmlmultiple="true">User</QPM:TargetAudience>
    7.52              </QPM:ContentDescription>
    7.53              <QPM:LicenseUrl>repdata://LicenseUrl/COPYING</QPM:LicenseUrl>
    7.54 +         </QPM:PackageManifest>
    7.55 +      </QPG:PackageFilter>
    7.56 +
    7.57 +      <QPG:PackageFilter proc="none" target="none">
    7.58 +         <QPM:PackageManifest>
    7.59              <QPM:ProductInstallationDependencies>
    7.60 -               <QPM:ProductRequirements/>
    7.61 +               <QPM:ProductRequirements></QPM:ProductRequirements>
    7.62              </QPM:ProductInstallationDependencies>
    7.63           </QPM:PackageManifest>
    7.64        </QPG:PackageFilter>
    7.65 +
    7.66 +      <QPG:PackageFilter proc="x86" target="none">
    7.67 +         <QPM:PackageManifest>
    7.68 +            <QPM:ProductInstallationDependencies>
    7.69 +               <QPM:ProductRequirements></QPM:ProductRequirements>
    7.70 +            </QPM:ProductInstallationDependencies>
    7.71 +         </QPM:PackageManifest>
    7.72 +      </QPG:PackageFilter>
    7.73 +
    7.74 +      <QPG:PackageFilter proc="none" target="x86">
    7.75 +         <QPM:PackageManifest>
    7.76 +            <QPM:ProductInstallationDependencies>
    7.77 +               <QPM:ProductRequirements></QPM:ProductRequirements>
    7.78 +            </QPM:ProductInstallationDependencies>
    7.79 +         </QPM:PackageManifest>
    7.80 +      </QPG:PackageFilter>
    7.81 +
    7.82 +      <QPG:PackageFilter proc="x86" target="x86">
    7.83 +         <QPM:PackageManifest>
    7.84 +            <QPM:ProductInstallationDependencies>
    7.85 +               <QPM:ProductRequirements></QPM:ProductRequirements>
    7.86 +            </QPM:ProductInstallationDependencies>
    7.87 +         </QPM:PackageManifest>
    7.88 +      </QPG:PackageFilter>
    7.89 +
    7.90     </QPG:Values>
    7.91  </QPG:Generation>
    7.92 -