Skip to content

Commit

Permalink
This is fix for failure of compilation on new libpng
Browse files Browse the repository at this point in the history
  • Loading branch information
alex8664 committed Mar 31, 2012
1 parent 686a211 commit 67411cb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tools/quake3/q3map2/image.c
Expand Up @@ -123,12 +123,11 @@ void PNGReadData( png_struct *png, png_byte *buffer, png_size_t size ){
static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, int *height ){
png_struct *png;
png_info *info, *end;
pngBuffer_t pb;
pngBuffer_t *pb = (pngBuffer_t*) png_get_io_ptr( png );

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Apr 14, 2012

Contributor

This cannot be right: png is used uninitialized here.

This comment has been minimized.

Copy link
@TTimo

TTimo Apr 14, 2012

Owner

You're right this looks messed up. I doubt it was tested, there are no png images in the Q3Pack, this is all I've been running against so far.

int i, bitDepth, colorType, channels;
png_uint_32 w, h;
byte **rowPointers;


/* dummy check */
if ( buffer == NULL || size <= 0 || pixels == NULL || width == NULL || height == NULL ) {
return;
Expand Down Expand Up @@ -167,14 +166,14 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in
}

/* set read callback */
pb.buffer = buffer;
pb.size = size;
pb.offset = 0;
pb->buffer = buffer;
pb->size = size;
pb->offset = 0;
png_set_read_fn( png, &pb, PNGReadData );
png->io_ptr = &pb; /* hack! */
//png->io_ptr = &pb; /* hack! */

/* set error longjmp */
if ( setjmp( png->jmpbuf ) ) {
if ( setjmp( png_jmpbuf(png) ) ) {
Sys_Printf( "WARNING: An error occurred reading PNG image\n" );
png_destroy_read_struct( &png, &info, &end );
return;
Expand Down

0 comments on commit 67411cb

Please sign in to comment.