diff options
Diffstat (limited to 'pngtest.c')
-rw-r--r-- | pngtest.c | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -1,7 +1,7 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.4.0 [January 1, 2010] + * Last changed in libpng 1.4.0 [January 2, 2010] * Copyright (c) 1998-2010 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -267,12 +267,17 @@ static int wrote_question = 0; static void pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_size_t check; + png_size_t check = 0; + png_voidp io_ptr; /* fread() returns 0 on error, so it is OK to store this in a png_size_t * instead of an int, which is what fread() actually returns. */ - check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr); + io_ptr = png_get_io_ptr(png_ptr); + if (io_ptr != NULL) + { + check = fread(data, 1, length, (png_FILE_p)io_ptr); + } if (check != length) { @@ -412,9 +417,12 @@ static void pngtest_warning(png_structp png_ptr, png_const_charp message) { PNG_CONST char *name = "UNKNOWN (ERROR!)"; - if (png_ptr != NULL && png_ptr->error_ptr != NULL) - name = png_ptr->error_ptr; - fprintf(STDERR, "%s: libpng warning: %s\n", name, message); + char *test; + test = png_get_error_ptr(png_ptr); + if (test == NULL) + fprintf(STDERR, "%s: libpng warning: %s\n", name, message); + else + fprintf(STDERR, "%s: libpng warning: %s\n", test, message); } /* This is the default error handling function. Note that replacements for @@ -1619,4 +1627,4 @@ main(int argc, char *argv[]) } /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_4_0rc07 your_png_h_is_not_version_1_4_0rc07; +typedef version_1_4_0rc08 your_png_h_is_not_version_1_4_0rc08; |