Skip to content

Commit

Permalink
Date: Fri, 19 Dec 2003 18:47:46 +0200
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Dec 19, 2003
1 parent cbcb089 commit 46c847e
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 32 deletions.
12 changes: 9 additions & 3 deletions IMG.c
Expand Up @@ -39,7 +39,7 @@ static struct {
SDL_Surface *(*load)(SDL_RWops *src);
} supported[] = {
/* keep magicless formats first */
{ "TGA", 0, IMG_LoadTGA_RW },
{ "TGA", NULL, IMG_LoadTGA_RW },
{ "BMP", IMG_isBMP, IMG_LoadBMP_RW },
{ "PNM", IMG_isPNM, IMG_LoadPNM_RW }, /* P[BGP]M share code */
{ "XPM", IMG_isXPM, IMG_LoadXPM_RW },
Expand All @@ -64,8 +64,13 @@ SDL_Surface *IMG_Load(const char *file)
{
SDL_RWops *src = SDL_RWFromFile(file, "rb");
char *ext = strrchr(file, '.');
if(ext)
ext++;
if(ext) {
ext++;
}
if(!src) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}
return IMG_LoadTyped_RW(src, 1, ext);
}

Expand Down Expand Up @@ -96,6 +101,7 @@ SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type)

/* Make sure there is something to do.. */
if ( src == NULL ) {
IMG_SetError("Passed a NULL data source");
return(NULL);
}

Expand Down
2 changes: 0 additions & 2 deletions IMG_lbm.c
Expand Up @@ -91,8 +91,6 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src )
error = NULL;
MiniBuf = NULL;

if ( src == NULL ) goto done;

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

if ( ! src ) {
goto done;
}

if ( ! SDL_RWread(src, &pcxh, sizeof(pcxh), 1) ) {
error = "file truncated";
goto done;
Expand Down
5 changes: 0 additions & 5 deletions IMG_png.c
Expand Up @@ -114,11 +114,6 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
/* Initialize the data we will clean up when we're done */
png_ptr = NULL; info_ptr = NULL; row_pointers = NULL; surface = NULL;

/* Check to make sure we have something to do */
if ( ! src ) {
goto done;
}

/* Create the PNG loading context structure */
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
NULL,NULL,NULL);
Expand Down
3 changes: 0 additions & 3 deletions IMG_pnm.c
Expand Up @@ -108,9 +108,6 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src)

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

if(!src)
return NULL;

SDL_RWread(src, magic, 2, 1);
kind = magic[1] - '1';
ascii = 1;
Expand Down
5 changes: 0 additions & 5 deletions IMG_xcf.c
Expand Up @@ -678,11 +678,6 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) {

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

/* Check to make sure we have something to do */
if ( ! src ) {
return NULL;
}

/* Initialize the data we will clean up when we're done */
surface = NULL;
read_error = 0;
Expand Down
52 changes: 42 additions & 10 deletions SDL_image.qpg.in
Expand Up @@ -37,13 +37,15 @@
</QPG:Files>
<QPG:PackageFilter>
<QPM:PackageManifest>

<QPM:PackageDescription>
<QPM:PackageType>Library</QPM:PackageType>
<QPM:PackageName>SDL_image</QPM:PackageName>
<QPM:PackageReleaseNumber>1</QPM:PackageReleaseNumber>
<QPM:PackageRepository>http://qnx.org.ru/repository</QPM:PackageRepository>
<QPM:FileVersion>2.0</QPM:FileVersion>
</QPM:PackageDescription>

<QPM:ProductDescription>
<QPM:ProductName>SDL_image</QPM:ProductName>
<QPM:ProductIdentifier>SDL_image</QPM:ProductIdentifier>
Expand All @@ -61,9 +63,10 @@
<QPM:ProductIconLarge/>
<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>
<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>
<QPM:ProductDescriptionURL>http://www.libsdl.org</QPM:ProductDescriptionURL>
<QPM:ProductDescriptionURL>http://www.libsdl.org/projects/SDL_image</QPM:ProductDescriptionURL>
<QPM:ProductDescriptionEmbedURL/>
</QPM:ProductDescription>

<QPM:ReleaseDescription>
<QPM:ReleaseVersion>@VERSION@</QPM:ReleaseVersion>
<QPM:ReleaseUrgency>High</QPM:ReleaseUrgency>
Expand All @@ -74,23 +77,52 @@
<QPM:CountryExclude/>
<QPM:ReleaseCopyright>GNU General Public License</QPM:ReleaseCopyright>
</QPM:ReleaseDescription>

<QPM:ContentDescription>
<QPM:ContentTopic>Software Development/Libraries and Extensions/C Libraries</QPM:ContentTopic>
<QPM:ContentTopic xmlmultiple="true">Software Development/Libraries and Extensions/C Libraries</QPM:ContentTopic>
<QPM:ContentKeyword>SDL, graphics, images, BMP, PPM, PCX, GIF, JPEG, PNG, TIFF</QPM:ContentKeyword>
<QPM:Processor/>
<QPM:TargetProcessor/>
<QPM:TargetOS>qnx6</QPM:TargetOS>
<QPM:HostOS>qnx6</QPM:HostOS>
<QPM:DisplayEnvironment>Photon</QPM:DisplayEnvironment>
<QPM:TargetAudience>Developer</QPM:TargetAudience>
<QPM:TargetAudience>User</QPM:TargetAudience>
<QPM:HostOS>none</QPM:HostOS>
<QPM:DisplayEnvironment xmlmultiple="true">Photon</QPM:DisplayEnvironment>
<QPM:DisplayEnvironment xmlmultiple="true">Console</QPM:DisplayEnvironment>
<QPM:TargetAudience xmlmultiple="true">Developer</QPM:TargetAudience>
<QPM:TargetAudience xmlmultiple="true">User</QPM:TargetAudience>
</QPM:ContentDescription>
<QPM:LicenseUrl>repdata://LicenseUrl/COPYING</QPM:LicenseUrl>
</QPM:PackageManifest>
</QPG:PackageFilter>

<QPG:PackageFilter proc="none" target="none">
<QPM:PackageManifest>
<QPM:ProductInstallationDependencies>
<QPM:ProductRequirements></QPM:ProductRequirements>
</QPM:ProductInstallationDependencies>
</QPM:PackageManifest>
</QPG:PackageFilter>

<QPG:PackageFilter proc="x86" target="none">
<QPM:PackageManifest>
<QPM:ProductInstallationDependencies>
<QPM:ProductRequirements/>
<QPM:ProductRequirements></QPM:ProductRequirements>
</QPM:ProductInstallationDependencies>
</QPM:PackageManifest>
</QPG:PackageFilter>

<QPG:PackageFilter proc="none" target="x86">
<QPM:PackageManifest>
<QPM:ProductInstallationDependencies>
<QPM:ProductRequirements></QPM:ProductRequirements>
</QPM:ProductInstallationDependencies>
</QPM:PackageManifest>
</QPG:PackageFilter>

<QPG:PackageFilter proc="x86" target="x86">
<QPM:PackageManifest>
<QPM:ProductInstallationDependencies>
<QPM:ProductRequirements></QPM:ProductRequirements>
</QPM:ProductInstallationDependencies>
</QPM:PackageManifest>
</QPG:PackageFilter>

</QPG:Values>
</QPG:Generation>

0 comments on commit 46c847e

Please sign in to comment.