| OLD | NEW |
| 1 | 1 |
| 2 /* pngerror.c - stub functions for i/o and memory allocation | 2 /* pngerror.c - stub functions for i/o and memory allocation |
| 3 * | 3 * |
| 4 * Last changed in libpng 1.2.41 [December 3, 2009] | 4 * Last changed in libpng 1.2.45 [July 7, 2011] |
| 5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson | 5 * Copyright (c) 1998-2011 Glenn Randers-Pehrson |
| 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) | 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
| 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) | 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
| 8 * | 8 * |
| 9 * This code is released under the libpng license. | 9 * This code is released under the libpng license. |
| 10 * For conditions of distribution and use, see the disclaimer | 10 * For conditions of distribution and use, see the disclaimer |
| 11 * and license in png.h | 11 * and license in png.h |
| 12 * | 12 * |
| 13 * This file provides a location for all error handling. Users who | 13 * This file provides a location for all error handling. Users who |
| 14 * need special error handling are expected to write replacement functions | 14 * need special error handling are expected to write replacement functions |
| 15 * and use png_set_error_fn() to use those functions. See the instructions | 15 * and use png_set_error_fn() to use those functions. See the instructions |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 (*(png_ptr->error_fn))(png_ptr, error_message); | 80 (*(png_ptr->error_fn))(png_ptr, error_message); |
| 81 | 81 |
| 82 /* If the custom handler doesn't exist, or if it returns, | 82 /* If the custom handler doesn't exist, or if it returns, |
| 83 use the default handler, which will not return. */ | 83 use the default handler, which will not return. */ |
| 84 png_default_error(png_ptr, error_message); | 84 png_default_error(png_ptr, error_message); |
| 85 } | 85 } |
| 86 #else | 86 #else |
| 87 void PNGAPI | 87 void PNGAPI |
| 88 png_err(png_structp png_ptr) | 88 png_err(png_structp png_ptr) |
| 89 { | 89 { |
| 90 /* Prior to 1.2.45 the error_fn received a NULL pointer, expressed |
| 91 * erroneously as '\0', instead of the empty string "". This was |
| 92 * apparently an error, introduced in libpng-1.2.20, and png_default_error |
| 93 * will crash in this case. |
| 94 */ |
| 90 if (png_ptr != NULL && png_ptr->error_fn != NULL) | 95 if (png_ptr != NULL && png_ptr->error_fn != NULL) |
| 91 (*(png_ptr->error_fn))(png_ptr, '\0'); | 96 (*(png_ptr->error_fn))(png_ptr, ""); |
| 92 | 97 |
| 93 /* If the custom handler doesn't exist, or if it returns, | 98 /* If the custom handler doesn't exist, or if it returns, |
| 94 use the default handler, which will not return. */ | 99 use the default handler, which will not return. */ |
| 95 png_default_error(png_ptr, '\0'); | 100 png_default_error(png_ptr, ""); |
| 96 } | 101 } |
| 97 #endif /* PNG_ERROR_TEXT_SUPPORTED */ | 102 #endif /* PNG_ERROR_TEXT_SUPPORTED */ |
| 98 | 103 |
| 99 #ifdef PNG_WARNINGS_SUPPORTED | 104 #ifdef PNG_WARNINGS_SUPPORTED |
| 100 /* This function is called whenever there is a non-fatal error. This function | 105 /* This function is called whenever there is a non-fatal error. This function |
| 101 * should not be changed. If there is a need to handle warnings differently, | 106 * should not be changed. If there is a need to handle warnings differently, |
| 102 * you should supply a replacement warning function and use | 107 * you should supply a replacement warning function and use |
| 103 * png_set_error_fn() to replace the warning function at run-time. | 108 * png_set_error_fn() to replace the warning function at run-time. |
| 104 */ | 109 */ |
| 105 void PNGAPI | 110 void PNGAPI |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 buffer[iout++] = (png_byte)c; | 179 buffer[iout++] = (png_byte)c; |
| 175 } | 180 } |
| 176 } | 181 } |
| 177 | 182 |
| 178 if (error_message == NULL) | 183 if (error_message == NULL) |
| 179 buffer[iout] = '\0'; | 184 buffer[iout] = '\0'; |
| 180 else | 185 else |
| 181 { | 186 { |
| 182 buffer[iout++] = ':'; | 187 buffer[iout++] = ':'; |
| 183 buffer[iout++] = ' '; | 188 buffer[iout++] = ' '; |
| 184 png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT); | 189 |
| 185 buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0'; | 190 iin = 0; |
| 191 while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0') |
| 192 buffer[iout++] = error_message[iin++]; |
| 193 |
| 194 /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */ |
| 195 buffer[iout] = '\0'; |
| 186 } | 196 } |
| 187 } | 197 } |
| 188 | 198 |
| 189 #ifdef PNG_READ_SUPPORTED | 199 #ifdef PNG_READ_SUPPORTED |
| 190 void PNGAPI | 200 void PNGAPI |
| 191 png_chunk_error(png_structp png_ptr, png_const_charp error_message) | 201 png_chunk_error(png_structp png_ptr, png_const_charp error_message) |
| 192 { | 202 { |
| 193 char msg[18+PNG_MAX_ERROR_TEXT]; | 203 char msg[18+PNG_MAX_ERROR_TEXT]; |
| 194 if (png_ptr == NULL) | 204 if (png_ptr == NULL) |
| 195 png_error(png_ptr, error_message); | 205 png_error(png_ptr, error_message); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) | 387 png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) |
| 378 { | 388 { |
| 379 if (png_ptr != NULL) | 389 if (png_ptr != NULL) |
| 380 { | 390 { |
| 381 png_ptr->flags &= | 391 png_ptr->flags &= |
| 382 ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); | 392 ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); |
| 383 } | 393 } |
| 384 } | 394 } |
| 385 #endif | 395 #endif |
| 386 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ | 396 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |
| OLD | NEW |