Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1481)

Side by Side Diff: third_party/libpng/png.c

Issue 1467263003: third_party/libpng: update to 1.2.54 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* png.c - location for general purpose libpng functions 2 /* png.c - location for general purpose libpng functions
3 * 3 *
4 * Last changed in libpng 1.2.51 [February 6, 2014] 4 * Last changed in libpng 1.2.54 [November 12, 2015]
5 * Copyright (c) 1998-2014 Glenn Randers-Pehrson 5 * Copyright (c) 1998-2015 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 13
14 #define PNG_INTERNAL 14 #define PNG_INTERNAL
15 #define PNG_NO_EXTERN 15 #define PNG_NO_EXTERN
16 #define PNG_NO_PEDANTIC_WARNINGS 16 #define PNG_NO_PEDANTIC_WARNINGS
17 #include "png.h" 17 #include "png.h"
18 18
19 /* Generate a compiler error if there is an old png.h in the search path. */ 19 /* Generate a compiler error if there is an old png.h in the search path. */
20 typedef version_1_2_52 Your_png_h_is_not_version_1_2_52; 20 typedef version_1_2_54 Your_png_h_is_not_version_1_2_54;
21 21
22 /* Version information for C files. This had better match the version 22 /* Version information for C files. This had better match the version
23 * string defined in png.h. 23 * string defined in png.h.
24 */ 24 */
25 25
26 #ifdef PNG_USE_GLOBAL_ARRAYS 26 #ifdef PNG_USE_GLOBAL_ARRAYS
27 /* png_libpng_ver was changed to a function in version 1.0.5c */ 27 /* png_libpng_ver was changed to a function in version 1.0.5c */
28 PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; 28 PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
29 29
30 #ifdef PNG_READ_SUPPORTED 30 #ifdef PNG_READ_SUPPORTED
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 151 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
152 /* Function to allocate memory for zlib and clear it to 0. */ 152 /* Function to allocate memory for zlib and clear it to 0. */
153 #ifdef PNG_1_0_X 153 #ifdef PNG_1_0_X
154 voidpf PNGAPI 154 voidpf PNGAPI
155 #else 155 #else
156 voidpf /* PRIVATE */ 156 voidpf /* PRIVATE */
157 #endif 157 #endif
158 png_zalloc(voidpf png_ptr, uInt items, uInt size) 158 png_zalloc(voidpf png_ptr, uInt items, uInt size)
159 { 159 {
160 png_voidp ptr; 160 png_voidp ptr;
161 png_structp p=(png_structp)png_ptr; 161 png_structp p;
162 png_uint_32 save_flags=p->flags; 162 png_uint_32 save_flags;
163 png_uint_32 num_bytes; 163 png_uint_32 num_bytes;
164 164
165 if (png_ptr == NULL) 165 if (png_ptr == NULL)
166 return (NULL); 166 return (NULL);
167
168 p=(png_structp)png_ptr;
169 save_flags=p->flags;
170
167 if (items > PNG_UINT_32_MAX/size) 171 if (items > PNG_UINT_32_MAX/size)
168 { 172 {
169 png_warning (p, "Potential overflow in png_zalloc()"); 173 png_warning (p, "Potential overflow in png_zalloc()");
170 return (NULL); 174 return (NULL);
171 } 175 }
172 num_bytes = (png_uint_32)items * size; 176 num_bytes = (png_uint_32)items * size;
173 177
174 p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; 178 p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
175 ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); 179 ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
176 p->flags=save_flags; 180 p->flags=save_flags;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 png_debug(1, "in png_info_init_3"); 325 png_debug(1, "in png_info_init_3");
322 326
323 if (info_ptr == NULL) 327 if (info_ptr == NULL)
324 return; 328 return;
325 329
326 if (png_sizeof(png_info) > png_info_struct_size) 330 if (png_sizeof(png_info) > png_info_struct_size)
327 { 331 {
328 png_destroy_struct(info_ptr); 332 png_destroy_struct(info_ptr);
329 info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); 333 info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
330 *ptr_ptr = info_ptr; 334 *ptr_ptr = info_ptr;
335 if (info_ptr == NULL)
336 return;
331 } 337 }
332 338
333 /* Set everything to 0 */ 339 /* Set everything to 0 */
334 png_memset(info_ptr, 0, png_sizeof(png_info)); 340 png_memset(info_ptr, 0, png_sizeof(png_info));
335 } 341 }
336 342
337 #ifdef PNG_FREE_ME_SUPPORTED 343 #ifdef PNG_FREE_ME_SUPPORTED
338 void PNGAPI 344 void PNGAPI
339 png_data_freer(png_structp png_ptr, png_infop info_ptr, 345 png_data_freer(png_structp png_ptr, png_infop info_ptr,
340 int freer, png_uint_32 mask) 346 int freer, png_uint_32 mask)
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 */ 674 */
669 png_charp PNGAPI 675 png_charp PNGAPI
670 png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) 676 png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
671 { 677 {
672 static PNG_CONST char short_months[12][4] = 678 static PNG_CONST char short_months[12][4] =
673 {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 679 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
674 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 680 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
675 681
676 if (png_ptr == NULL) 682 if (png_ptr == NULL)
677 return (NULL); 683 return (NULL);
684
678 if (png_ptr->time_buffer == NULL) 685 if (png_ptr->time_buffer == NULL)
679 { 686 {
680 png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* 687 png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
681 png_sizeof(char))); 688 png_sizeof(char)));
682 } 689 }
683 690
684 #ifdef _WIN32_WCE 691 #ifdef _WIN32_WCE
685 { 692 {
686 wchar_t time_buf[29]; 693 wchar_t time_buf[29];
687 wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), 694 wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"),
688 ptime->day % 32, short_months[(ptime->month - 1) % 12], 695 ptime->day % 32, short_months[(ptime->month - 1U) % 12],
689 ptime->year, ptime->hour % 24, ptime->minute % 60, 696 ptime->year, ptime->hour % 24, ptime->minute % 60,
690 ptime->second % 61); 697 ptime->second % 61);
691 WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 698 WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer,
692 29, NULL, NULL); 699 29, NULL, NULL);
693 } 700 }
694 #else 701 #else
695 #ifdef USE_FAR_KEYWORD 702 #ifdef USE_FAR_KEYWORD
696 { 703 {
697 char near_time_buf[29]; 704 char near_time_buf[29];
698 png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000", 705 png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000",
699 ptime->day % 32, short_months[(ptime->month - 1) % 12], 706 ptime->day % 32, short_months[(ptime->month - 1U) % 12],
700 ptime->year, ptime->hour % 24, ptime->minute % 60, 707 ptime->year, ptime->hour % 24, ptime->minute % 60,
701 ptime->second % 61); 708 ptime->second % 61);
702 png_memcpy(png_ptr->time_buffer, near_time_buf, 709 png_memcpy(png_ptr->time_buffer, near_time_buf,
703 29*png_sizeof(char)); 710 29*png_sizeof(char));
704 } 711 }
705 #else 712 #else
706 png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000", 713 png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000",
707 ptime->day % 32, short_months[(ptime->month - 1) % 12], 714 ptime->day % 32, short_months[(ptime->month - 1U) % 12],
708 ptime->year, ptime->hour % 24, ptime->minute % 60, 715 ptime->year, ptime->hour % 24, ptime->minute % 60,
709 ptime->second % 61); 716 ptime->second % 61);
710 #endif 717 #endif
711 #endif /* _WIN32_WCE */ 718 #endif /* _WIN32_WCE */
712 return ((png_charp)png_ptr->time_buffer); 719 return ((png_charp)png_ptr->time_buffer);
713 } 720 }
714 #endif /* PNG_TIME_RFC1123_SUPPORTED */ 721 #endif /* PNG_TIME_RFC1123_SUPPORTED */
715 722
716 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ 723 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
717 724
718 png_charp PNGAPI 725 png_charp PNGAPI
719 png_get_copyright(png_structp png_ptr) 726 png_get_copyright(png_structp png_ptr)
720 { 727 {
721 PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ 728 PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */
722 #ifdef PNG_STRING_COPYRIGHT 729 #ifdef PNG_STRING_COPYRIGHT
723 return PNG_STRING_COPYRIGHT 730 return PNG_STRING_COPYRIGHT
724 #else 731 #else
725 #ifdef __STDC__ 732 #ifdef __STDC__
726 return ((png_charp) PNG_STRING_NEWLINE \ 733 return ((png_charp) PNG_STRING_NEWLINE \
727 "libpng version 1.2.52 - November 20, 2014" PNG_STRING_NEWLINE \ 734 "libpng version 1.2.54 - November 12, 2015" PNG_STRING_NEWLINE \
728 "Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ 735 "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
729 "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ 736 "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
730 "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ 737 "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
731 PNG_STRING_NEWLINE); 738 PNG_STRING_NEWLINE);
732 #else 739 #else
733 return ((png_charp) "libpng version 1.2.52 - November 20, 2014\ 740 return ((png_charp) "libpng version 1.2.54 - November 12, 2015\
734 Copyright (c) 1998-2014 Glenn Randers-Pehrson\ 741 Copyright (c) 1998-2015 Glenn Randers-Pehrson\
735 Copyright (c) 1996-1997 Andreas Dilger\ 742 Copyright (c) 1996-1997 Andreas Dilger\
736 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."); 743 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
737 #endif 744 #endif
738 #endif 745 #endif
739 } 746 }
740 747
741 /* The following return the library version as a short string in the 748 /* The following return the library version as a short string in the
742 * format 1.0.0 through 99.99.99zz. To get the version of *.h files 749 * format 1.0.0 through 99.99.99zz. To get the version of *.h files
743 * used with your application, print out PNG_LIBPNG_VER_STRING, which 750 * used with your application, print out PNG_LIBPNG_VER_STRING, which
744 * is defined in png.h. 751 * is defined in png.h.
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 { 1090 {
1084 png_warning(png_ptr, "Unknown filter method in IHDR"); 1091 png_warning(png_ptr, "Unknown filter method in IHDR");
1085 error = 1; 1092 error = 1;
1086 } 1093 }
1087 #endif 1094 #endif
1088 1095
1089 if (error == 1) 1096 if (error == 1)
1090 png_error(png_ptr, "Invalid IHDR data"); 1097 png_error(png_ptr, "Invalid IHDR data");
1091 } 1098 }
1092 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ 1099 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698