~ubuntu-branches/ubuntu/precise/libpng/precise

« back to all changes in this revision

Viewing changes to pngerror.c

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-07-27 12:44:46 UTC
  • mfrom: (1.3.7 upstream)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: james.westby@ubuntu.com-20110727124446-x8ctn5p2i29prtje
Tags: upstream-1.2.46
ImportĀ upstreamĀ versionĀ 1.2.46

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/* pngerror.c - stub functions for i/o and memory allocation
3
3
 *
4
 
 * Last changed in libpng 1.2.41 [December 3, 2009]
5
 
 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
 
4
 * Last changed in libpng 1.2.45 [July 7, 2011]
 
5
 * Copyright (c) 1998-2011 Glenn Randers-Pehrson
6
6
 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
7
7
 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
8
8
 *
87
87
void PNGAPI
88
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
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
98
   /* If the custom handler doesn't exist, or if it returns,
94
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
102
#endif /* PNG_ERROR_TEXT_SUPPORTED */
98
103
 
181
186
   {
182
187
      buffer[iout++] = ':';
183
188
      buffer[iout++] = ' ';
184
 
      png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
185
 
      buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
 
189
 
 
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