@@ -429,31 +429,31 @@ static int texLoadAll(GSTEXTURE *texture, const char *filePath, int texId, int a
429429 readData = & PngFileBufferPtr ;
430430 readFunction = & texReadMemFunction ;
431431 } else if (filePath ) {
432- int fd = open (filePath , O_RDONLY , 0 );
433- if (fd < 0 ) {
434- return ERR_BAD_FILE ;
435- }
436- int fileSize = lseek (fd , 0 , SEEK_END );
437- lseek (fd , 0 , SEEK_SET );
438-
439- pFileBuffer = malloc (fileSize );
440- if (pFileBuffer == NULL ) {
441- close (fd );
442- return ERR_BAD_FILE ; // There's no out of memory error...
443- }
444-
445- if (read (fd , pFileBuffer , fileSize ) != fileSize ) {
446- LOG ("texLoadAll: failed to read file %s\n" , filePath );
447- free (pFileBuffer );
448- close (fd );
449- return ERR_BAD_FILE ;
450- }
432+ int fd = open (filePath , O_RDONLY , 0 );
433+ if (fd < 0 ) {
434+ return ERR_BAD_FILE ;
435+ }
436+ int fileSize = lseek (fd , 0 , SEEK_END );
437+ lseek (fd , 0 , SEEK_SET );
451438
439+ pFileBuffer = malloc (fileSize );
440+ if (pFileBuffer == NULL ) {
452441 close (fd );
442+ return ERR_BAD_FILE ; // There's no out of memory error...
443+ }
453444
454- PngFileBufferPtr = pFileBuffer ;
455- readData = & PngFileBufferPtr ;
456- readFunction = & texReadMemFunction ;
445+ if (read (fd , pFileBuffer , fileSize ) != fileSize ) {
446+ LOG ("texLoadAll: failed to read file %s\n" , filePath );
447+ free (pFileBuffer );
448+ close (fd );
449+ return ERR_BAD_FILE ;
450+ }
451+
452+ close (fd );
453+
454+ PngFileBufferPtr = pFileBuffer ;
455+ readData = & PngFileBufferPtr ;
456+ readFunction = & texReadMemFunction ;
457457 } else {
458458 if (texId == -1 || !internalDefault [texId ].texture )
459459 return ERR_BAD_FILE ;
@@ -498,7 +498,7 @@ static int texLoadAll(GSTEXTURE *texture, const char *filePath, int texId, int a
498498 png_set_filler (pngPtr , 0xff , PNG_FILLER_AFTER );
499499 png_read_update_info (pngPtr , infoPtr );
500500
501- void (* texPngReadPixels )(GSTEXTURE * texture , png_bytep * rowPointers , size_t size );
501+ void (* texPngReadPixels )(GSTEXTURE * texture , png_bytep * rowPointers , size_t size );
502502 switch (png_get_color_type (pngPtr , infoPtr )) {
503503 case PNG_COLOR_TYPE_RGB_ALPHA :
504504 texture -> PSM = GS_PSM_CT32 ;
0 commit comments