• Home
  • Raw
  • Download

Lines Matching refs:png_ptr

29 __inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr,  in png_strtod()  argument
37 str = (wchar_t *)png_malloc(png_ptr, len * png_sizeof(wchar_t)); in png_strtod()
44 png_free(png_ptr, str); in png_strtod()
54 png_get_uint_31(png_structp png_ptr, png_bytep buf) in png_get_uint_31() argument
66 png_error(png_ptr, "PNG unsigned integer out of range."); in png_get_uint_31()
112 png_read_chunk_header(png_structp png_ptr) in png_read_chunk_header() argument
118 png_read_data(png_ptr, buf, 8); in png_read_chunk_header()
119 length = png_get_uint_31(png_ptr, buf); in png_read_chunk_header()
122 png_memcpy(png_ptr->chunk_name, buf + 4, 4); in png_read_chunk_header()
125 png_ptr->chunk_name, length); in png_read_chunk_header()
128 png_reset_crc(png_ptr); in png_read_chunk_header()
129 png_calculate_crc(png_ptr, png_ptr->chunk_name, 4); in png_read_chunk_header()
132 png_check_chunk_name(png_ptr, png_ptr->chunk_name); in png_read_chunk_header()
139 png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) in png_crc_read() argument
141 if (png_ptr == NULL) in png_crc_read()
143 png_read_data(png_ptr, buf, length); in png_crc_read()
144 png_calculate_crc(png_ptr, buf, length); in png_crc_read()
153 png_crc_finish(png_structp png_ptr, png_uint_32 skip) in png_crc_finish() argument
156 png_size_t istop = png_ptr->zbuf_size; in png_crc_finish()
160 png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); in png_crc_finish()
164 png_crc_read(png_ptr, png_ptr->zbuf, i); in png_crc_finish()
167 if (png_crc_error(png_ptr)) in png_crc_finish()
169 if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ in png_crc_finish()
170 !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || in png_crc_finish()
171 (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ in png_crc_finish()
172 (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) in png_crc_finish()
174 png_chunk_warning(png_ptr, "CRC error"); in png_crc_finish()
178 png_chunk_error(png_ptr, "CRC error"); in png_crc_finish()
190 png_crc_error(png_structp png_ptr) in png_crc_error() argument
196 if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ in png_crc_error()
198 if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == in png_crc_error()
204 if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) in png_crc_error()
208 png_read_data(png_ptr, crc_bytes, 4); in png_crc_error()
213 return ((int)(crc != png_ptr->crc)); in png_crc_error()
222 png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size, in png_inflate() argument
227 png_ptr->zstream.next_in = (png_bytep)data; /* const_cast: VALID */ in png_inflate()
228 png_ptr->zstream.avail_in = size; in png_inflate()
237 png_ptr->zstream.next_out = png_ptr->zbuf; in png_inflate()
238 png_ptr->zstream.avail_out = png_ptr->zbuf_size; in png_inflate()
240 ret = inflate(&png_ptr->zstream, Z_NO_FLUSH); in png_inflate()
241 avail = png_ptr->zbuf_size - png_ptr->zstream.avail_out; in png_inflate()
252 png_memcpy(output + count, png_ptr->zbuf, copy); in png_inflate()
263 png_ptr->zstream.avail_in = 0; in png_inflate()
264 inflateReset(&png_ptr->zstream); in png_inflate()
275 if (png_ptr->zstream.msg != 0) in png_inflate()
276 msg = png_ptr->zstream.msg; in png_inflate()
295 png_snprintf(umsg, sizeof umsg, msg, png_ptr->chunk_name); in png_inflate()
302 png_warning(png_ptr, msg); in png_inflate()
320 png_decompress_chunk(png_structp png_ptr, int comp_type, in png_decompress_chunk() argument
328 png_warning(png_ptr, "invalid chunklength"); in png_decompress_chunk()
334 png_size_t expanded_size = png_inflate(png_ptr, in png_decompress_chunk()
335 (png_bytep)(png_ptr->chunkdata + prefix_size), in png_decompress_chunk()
343 if (png_ptr->user_chunk_malloc_max && in png_decompress_chunk()
344 (prefix_size + expanded_size >= png_ptr->user_chunk_malloc_max - 1)) in png_decompress_chunk()
351 png_warning(png_ptr, "Exceeded size limit while expanding chunk"); in png_decompress_chunk()
366 png_charp text = png_malloc_warn(png_ptr, in png_decompress_chunk()
371 png_memcpy(text, png_ptr->chunkdata, prefix_size); in png_decompress_chunk()
372 new_size = png_inflate(png_ptr, in png_decompress_chunk()
373 (png_bytep)(png_ptr->chunkdata + prefix_size), in png_decompress_chunk()
380 png_free(png_ptr, png_ptr->chunkdata); in png_decompress_chunk()
381 png_ptr->chunkdata = text; in png_decompress_chunk()
386 png_warning(png_ptr, "png_inflate logic error"); in png_decompress_chunk()
387 png_free(png_ptr, text); in png_decompress_chunk()
390 png_warning(png_ptr, "Not enough memory to decompress chunk."); in png_decompress_chunk()
401 png_warning(png_ptr, umsg); in png_decompress_chunk()
403 png_warning(png_ptr, "Unknown zTXt compression type"); in png_decompress_chunk()
414 png_charp text = png_malloc_warn(png_ptr, prefix_size + 1); in png_decompress_chunk()
418 png_memcpy(text, png_ptr->chunkdata, prefix_size); in png_decompress_chunk()
419 png_free(png_ptr, png_ptr->chunkdata); in png_decompress_chunk()
420 png_ptr->chunkdata = text; in png_decompress_chunk()
423 *(png_ptr->chunkdata + prefix_size) = 0x00; in png_decompress_chunk()
434 png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_IHDR() argument
443 if (png_ptr->mode & PNG_HAVE_IHDR) in png_handle_IHDR()
444 png_error(png_ptr, "Out of place IHDR"); in png_handle_IHDR()
448 png_error(png_ptr, "Invalid IHDR chunk"); in png_handle_IHDR()
450 png_ptr->mode |= PNG_HAVE_IHDR; in png_handle_IHDR()
452 png_crc_read(png_ptr, buf, 13); in png_handle_IHDR()
453 png_crc_finish(png_ptr, 0); in png_handle_IHDR()
455 width = png_get_uint_31(png_ptr, buf); in png_handle_IHDR()
456 height = png_get_uint_31(png_ptr, buf + 4); in png_handle_IHDR()
464 png_ptr->width = width; in png_handle_IHDR()
465 png_ptr->height = height; in png_handle_IHDR()
466 png_ptr->bit_depth = (png_byte)bit_depth; in png_handle_IHDR()
467 png_ptr->interlaced = (png_byte)interlace_type; in png_handle_IHDR()
468 png_ptr->color_type = (png_byte)color_type; in png_handle_IHDR()
470 png_ptr->filter_type = (png_byte)filter_type; in png_handle_IHDR()
472 png_ptr->compression_type = (png_byte)compression_type; in png_handle_IHDR()
475 switch (png_ptr->color_type) in png_handle_IHDR()
479 png_ptr->channels = 1; in png_handle_IHDR()
483 png_ptr->channels = 3; in png_handle_IHDR()
487 png_ptr->channels = 2; in png_handle_IHDR()
491 png_ptr->channels = 4; in png_handle_IHDR()
496 png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * in png_handle_IHDR()
497 png_ptr->channels); in png_handle_IHDR()
498 png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width); in png_handle_IHDR()
499 png_debug1(3, "bit_depth = %d", png_ptr->bit_depth); in png_handle_IHDR()
500 png_debug1(3, "channels = %d", png_ptr->channels); in png_handle_IHDR()
501 png_debug1(3, "rowbytes = %lu", png_ptr->rowbytes); in png_handle_IHDR()
502 png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, in png_handle_IHDR()
508 png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_PLTE() argument
518 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_PLTE()
519 png_error(png_ptr, "Missing IHDR before PLTE"); in png_handle_PLTE()
521 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_PLTE()
523 png_warning(png_ptr, "Invalid PLTE after IDAT"); in png_handle_PLTE()
524 png_crc_finish(png_ptr, length); in png_handle_PLTE()
528 else if (png_ptr->mode & PNG_HAVE_PLTE) in png_handle_PLTE()
529 png_error(png_ptr, "Duplicate PLTE chunk"); in png_handle_PLTE()
531 png_ptr->mode |= PNG_HAVE_PLTE; in png_handle_PLTE()
533 if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) in png_handle_PLTE()
535 png_warning(png_ptr, in png_handle_PLTE()
537 png_crc_finish(png_ptr, length); in png_handle_PLTE()
541 if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) in png_handle_PLTE()
543 png_crc_finish(png_ptr, length); in png_handle_PLTE()
550 if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) in png_handle_PLTE()
552 png_warning(png_ptr, "Invalid palette chunk"); in png_handle_PLTE()
553 png_crc_finish(png_ptr, length); in png_handle_PLTE()
559 png_error(png_ptr, "Invalid palette chunk"); in png_handle_PLTE()
570 png_crc_read(png_ptr, buf, 3); in png_handle_PLTE()
580 png_crc_read(png_ptr, buf, 3); in png_handle_PLTE()
594 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_handle_PLTE()
597 png_crc_finish(png_ptr, 0); in png_handle_PLTE()
600 else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ in png_handle_PLTE()
606 if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) in png_handle_PLTE()
608 if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) in png_handle_PLTE()
610 png_chunk_error(png_ptr, "CRC error"); in png_handle_PLTE()
614 png_chunk_warning(png_ptr, "CRC error"); in png_handle_PLTE()
619 else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) in png_handle_PLTE()
621 png_chunk_warning(png_ptr, "CRC error"); in png_handle_PLTE()
626 png_set_PLTE(png_ptr, info_ptr, palette, num); in png_handle_PLTE()
629 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_handle_PLTE()
633 if (png_ptr->num_trans > (png_uint_16)num) in png_handle_PLTE()
635 png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); in png_handle_PLTE()
636 png_ptr->num_trans = (png_uint_16)num; in png_handle_PLTE()
640 png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); in png_handle_PLTE()
650 png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_IEND() argument
654 if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) in png_handle_IEND()
656 png_error(png_ptr, "No image in file"); in png_handle_IEND()
659 png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); in png_handle_IEND()
663 png_warning(png_ptr, "Incorrect IEND chunk length"); in png_handle_IEND()
665 png_crc_finish(png_ptr, length); in png_handle_IEND()
672 png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_gAMA() argument
682 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_gAMA()
683 png_error(png_ptr, "Missing IHDR before gAMA"); in png_handle_gAMA()
684 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_gAMA()
686 png_warning(png_ptr, "Invalid gAMA after IDAT"); in png_handle_gAMA()
687 png_crc_finish(png_ptr, length); in png_handle_gAMA()
690 else if (png_ptr->mode & PNG_HAVE_PLTE) in png_handle_gAMA()
692 png_warning(png_ptr, "Out of place gAMA chunk"); in png_handle_gAMA()
700 png_warning(png_ptr, "Duplicate gAMA chunk"); in png_handle_gAMA()
701 png_crc_finish(png_ptr, length); in png_handle_gAMA()
707 png_warning(png_ptr, "Incorrect gAMA chunk length"); in png_handle_gAMA()
708 png_crc_finish(png_ptr, length); in png_handle_gAMA()
712 png_crc_read(png_ptr, buf, 4); in png_handle_gAMA()
713 if (png_crc_finish(png_ptr, 0)) in png_handle_gAMA()
720 png_warning(png_ptr, in png_handle_gAMA()
729 png_warning(png_ptr, in png_handle_gAMA()
741 png_ptr->gamma = file_gamma; in png_handle_gAMA()
743 png_set_gAMA(png_ptr, info_ptr, file_gamma); in png_handle_gAMA()
746 png_set_gAMA_fixed(png_ptr, info_ptr, igamma); in png_handle_gAMA()
753 png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_sBIT() argument
762 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_sBIT()
763 png_error(png_ptr, "Missing IHDR before sBIT"); in png_handle_sBIT()
764 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_sBIT()
766 png_warning(png_ptr, "Invalid sBIT after IDAT"); in png_handle_sBIT()
767 png_crc_finish(png_ptr, length); in png_handle_sBIT()
770 else if (png_ptr->mode & PNG_HAVE_PLTE) in png_handle_sBIT()
773 png_warning(png_ptr, "Out of place sBIT chunk"); in png_handle_sBIT()
777 png_warning(png_ptr, "Duplicate sBIT chunk"); in png_handle_sBIT()
778 png_crc_finish(png_ptr, length); in png_handle_sBIT()
782 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_handle_sBIT()
785 truelen = (png_size_t)png_ptr->channels; in png_handle_sBIT()
789 png_warning(png_ptr, "Incorrect sBIT chunk length"); in png_handle_sBIT()
790 png_crc_finish(png_ptr, length); in png_handle_sBIT()
794 png_crc_read(png_ptr, buf, truelen); in png_handle_sBIT()
795 if (png_crc_finish(png_ptr, 0)) in png_handle_sBIT()
798 if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) in png_handle_sBIT()
800 png_ptr->sig_bit.red = buf[0]; in png_handle_sBIT()
801 png_ptr->sig_bit.green = buf[1]; in png_handle_sBIT()
802 png_ptr->sig_bit.blue = buf[2]; in png_handle_sBIT()
803 png_ptr->sig_bit.alpha = buf[3]; in png_handle_sBIT()
807 png_ptr->sig_bit.gray = buf[0]; in png_handle_sBIT()
808 png_ptr->sig_bit.red = buf[0]; in png_handle_sBIT()
809 png_ptr->sig_bit.green = buf[0]; in png_handle_sBIT()
810 png_ptr->sig_bit.blue = buf[0]; in png_handle_sBIT()
811 png_ptr->sig_bit.alpha = buf[1]; in png_handle_sBIT()
813 png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); in png_handle_sBIT()
819 png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_cHRM() argument
832 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_cHRM()
833 png_error(png_ptr, "Missing IHDR before cHRM"); in png_handle_cHRM()
834 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_cHRM()
836 png_warning(png_ptr, "Invalid cHRM after IDAT"); in png_handle_cHRM()
837 png_crc_finish(png_ptr, length); in png_handle_cHRM()
840 else if (png_ptr->mode & PNG_HAVE_PLTE) in png_handle_cHRM()
842 png_warning(png_ptr, "Missing PLTE before cHRM"); in png_handle_cHRM()
850 png_warning(png_ptr, "Duplicate cHRM chunk"); in png_handle_cHRM()
851 png_crc_finish(png_ptr, length); in png_handle_cHRM()
857 png_warning(png_ptr, "Incorrect cHRM chunk length"); in png_handle_cHRM()
858 png_crc_finish(png_ptr, length); in png_handle_cHRM()
862 png_crc_read(png_ptr, buf, 32); in png_handle_cHRM()
863 if (png_crc_finish(png_ptr, 0)) in png_handle_cHRM()
909 png_warning(png_ptr, in png_handle_cHRM()
932 png_set_cHRM(png_ptr, info_ptr, in png_handle_cHRM()
936 png_set_cHRM_fixed(png_ptr, info_ptr, in png_handle_cHRM()
945 png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_sRGB() argument
952 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_sRGB()
953 png_error(png_ptr, "Missing IHDR before sRGB"); in png_handle_sRGB()
954 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_sRGB()
956 png_warning(png_ptr, "Invalid sRGB after IDAT"); in png_handle_sRGB()
957 png_crc_finish(png_ptr, length); in png_handle_sRGB()
960 else if (png_ptr->mode & PNG_HAVE_PLTE) in png_handle_sRGB()
962 png_warning(png_ptr, "Out of place sRGB chunk"); in png_handle_sRGB()
966 png_warning(png_ptr, "Duplicate sRGB chunk"); in png_handle_sRGB()
967 png_crc_finish(png_ptr, length); in png_handle_sRGB()
973 png_warning(png_ptr, "Incorrect sRGB chunk length"); in png_handle_sRGB()
974 png_crc_finish(png_ptr, length); in png_handle_sRGB()
978 png_crc_read(png_ptr, buf, 1); in png_handle_sRGB()
979 if (png_crc_finish(png_ptr, 0)) in png_handle_sRGB()
986 png_warning(png_ptr, "Unknown sRGB intent"); in png_handle_sRGB()
1003 png_warning(png_ptr, in png_handle_sRGB()
1008 (int)png_ptr->int_gamma); in png_handle_sRGB()
1011 fprintf(stderr, "incorrect gamma=%f\n", png_ptr->gamma); in png_handle_sRGB()
1031 png_warning(png_ptr, in png_handle_sRGB()
1037 png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); in png_handle_sRGB()
1043 png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_iCCP() argument
1055 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_iCCP()
1056 png_error(png_ptr, "Missing IHDR before iCCP"); in png_handle_iCCP()
1057 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_iCCP()
1059 png_warning(png_ptr, "Invalid iCCP after IDAT"); in png_handle_iCCP()
1060 png_crc_finish(png_ptr, length); in png_handle_iCCP()
1063 else if (png_ptr->mode & PNG_HAVE_PLTE) in png_handle_iCCP()
1065 png_warning(png_ptr, "Out of place iCCP chunk"); in png_handle_iCCP()
1069 png_warning(png_ptr, "Duplicate iCCP chunk"); in png_handle_iCCP()
1070 png_crc_finish(png_ptr, length); in png_handle_iCCP()
1077 png_warning(png_ptr, "iCCP chunk too large to fit in memory"); in png_handle_iCCP()
1083 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iCCP()
1084 png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1); in png_handle_iCCP()
1086 png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); in png_handle_iCCP()
1088 if (png_crc_finish(png_ptr, skip)) in png_handle_iCCP()
1090 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iCCP()
1091 png_ptr->chunkdata = NULL; in png_handle_iCCP()
1095 png_ptr->chunkdata[slength] = 0x00; in png_handle_iCCP()
1097 for (profile = png_ptr->chunkdata; *profile; profile++) in png_handle_iCCP()
1105 if ( profile >= png_ptr->chunkdata + slength - 1) in png_handle_iCCP()
1107 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iCCP()
1108 png_ptr->chunkdata = NULL; in png_handle_iCCP()
1109 png_warning(png_ptr, "Malformed iCCP chunk"); in png_handle_iCCP()
1117 png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); in png_handle_iCCP()
1122 prefix_length = profile - png_ptr->chunkdata; in png_handle_iCCP()
1123 png_decompress_chunk(png_ptr, compression_type, in png_handle_iCCP()
1130 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iCCP()
1131 png_ptr->chunkdata = NULL; in png_handle_iCCP()
1132 png_warning(png_ptr, "Profile size field missing from iCCP chunk"); in png_handle_iCCP()
1137 pC = (png_bytep)(png_ptr->chunkdata + prefix_length); in png_handle_iCCP()
1148 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iCCP()
1149 png_ptr->chunkdata = NULL; in png_handle_iCCP()
1150 png_warning(png_ptr, "Ignoring truncated iCCP profile."); in png_handle_iCCP()
1154 png_set_iCCP(png_ptr, info_ptr, png_ptr->chunkdata, in png_handle_iCCP()
1155 compression_type, png_ptr->chunkdata + prefix_length, profile_length); in png_handle_iCCP()
1156 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iCCP()
1157 png_ptr->chunkdata = NULL; in png_handle_iCCP()
1163 png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_sPLT() argument
1179 if (png_ptr->user_chunk_cache_max != 0) in png_handle_sPLT()
1181 if (png_ptr->user_chunk_cache_max == 1) in png_handle_sPLT()
1183 png_crc_finish(png_ptr, length); in png_handle_sPLT()
1186 if (--png_ptr->user_chunk_cache_max == 1) in png_handle_sPLT()
1188 png_warning(png_ptr, "No space in chunk cache for sPLT"); in png_handle_sPLT()
1189 png_crc_finish(png_ptr, length); in png_handle_sPLT()
1195 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_sPLT()
1196 png_error(png_ptr, "Missing IHDR before sPLT"); in png_handle_sPLT()
1197 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_sPLT()
1199 png_warning(png_ptr, "Invalid sPLT after IDAT"); in png_handle_sPLT()
1200 png_crc_finish(png_ptr, length); in png_handle_sPLT()
1207 png_warning(png_ptr, "sPLT chunk too large to fit in memory"); in png_handle_sPLT()
1213 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sPLT()
1214 png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1); in png_handle_sPLT()
1216 png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); in png_handle_sPLT()
1218 if (png_crc_finish(png_ptr, skip)) in png_handle_sPLT()
1220 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sPLT()
1221 png_ptr->chunkdata = NULL; in png_handle_sPLT()
1225 png_ptr->chunkdata[slength] = 0x00; in png_handle_sPLT()
1227 for (entry_start = (png_bytep)png_ptr->chunkdata; *entry_start; in png_handle_sPLT()
1233 if (entry_start > (png_bytep)png_ptr->chunkdata + slength - 2) in png_handle_sPLT()
1235 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sPLT()
1236 png_ptr->chunkdata = NULL; in png_handle_sPLT()
1237 png_warning(png_ptr, "malformed sPLT chunk"); in png_handle_sPLT()
1243 data_length = (slength - (entry_start - (png_bytep)png_ptr->chunkdata)); in png_handle_sPLT()
1248 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sPLT()
1249 png_ptr->chunkdata = NULL; in png_handle_sPLT()
1250 png_warning(png_ptr, "sPLT chunk has bad length"); in png_handle_sPLT()
1258 png_warning(png_ptr, "sPLT chunk too long"); in png_handle_sPLT()
1262 png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry)); in png_handle_sPLT()
1265 png_warning(png_ptr, "sPLT chunk requires too much memory"); in png_handle_sPLT()
1314 new_palette.name = png_ptr->chunkdata; in png_handle_sPLT()
1316 png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); in png_handle_sPLT()
1318 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sPLT()
1319 png_ptr->chunkdata = NULL; in png_handle_sPLT()
1320 png_free(png_ptr, new_palette.entries); in png_handle_sPLT()
1326 png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_tRNS() argument
1332 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_tRNS()
1333 png_error(png_ptr, "Missing IHDR before tRNS"); in png_handle_tRNS()
1334 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_tRNS()
1336 png_warning(png_ptr, "Invalid tRNS after IDAT"); in png_handle_tRNS()
1337 png_crc_finish(png_ptr, length); in png_handle_tRNS()
1342 png_warning(png_ptr, "Duplicate tRNS chunk"); in png_handle_tRNS()
1343 png_crc_finish(png_ptr, length); in png_handle_tRNS()
1347 if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) in png_handle_tRNS()
1353 png_warning(png_ptr, "Incorrect tRNS chunk length"); in png_handle_tRNS()
1354 png_crc_finish(png_ptr, length); in png_handle_tRNS()
1358 png_crc_read(png_ptr, buf, 2); in png_handle_tRNS()
1359 png_ptr->num_trans = 1; in png_handle_tRNS()
1360 png_ptr->trans_values.gray = png_get_uint_16(buf); in png_handle_tRNS()
1362 else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) in png_handle_tRNS()
1368 png_warning(png_ptr, "Incorrect tRNS chunk length"); in png_handle_tRNS()
1369 png_crc_finish(png_ptr, length); in png_handle_tRNS()
1372 png_crc_read(png_ptr, buf, (png_size_t)length); in png_handle_tRNS()
1373 png_ptr->num_trans = 1; in png_handle_tRNS()
1374 png_ptr->trans_values.red = png_get_uint_16(buf); in png_handle_tRNS()
1375 png_ptr->trans_values.green = png_get_uint_16(buf + 2); in png_handle_tRNS()
1376 png_ptr->trans_values.blue = png_get_uint_16(buf + 4); in png_handle_tRNS()
1378 else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_handle_tRNS()
1380 if (!(png_ptr->mode & PNG_HAVE_PLTE)) in png_handle_tRNS()
1383 png_warning(png_ptr, "Missing PLTE before tRNS"); in png_handle_tRNS()
1385 if (length > (png_uint_32)png_ptr->num_palette || in png_handle_tRNS()
1388 png_warning(png_ptr, "Incorrect tRNS chunk length"); in png_handle_tRNS()
1389 png_crc_finish(png_ptr, length); in png_handle_tRNS()
1394 png_warning(png_ptr, "Zero length tRNS chunk"); in png_handle_tRNS()
1395 png_crc_finish(png_ptr, length); in png_handle_tRNS()
1398 png_crc_read(png_ptr, readbuf, (png_size_t)length); in png_handle_tRNS()
1399 png_ptr->num_trans = (png_uint_16)length; in png_handle_tRNS()
1403 png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); in png_handle_tRNS()
1404 png_crc_finish(png_ptr, length); in png_handle_tRNS()
1408 if (png_crc_finish(png_ptr, 0)) in png_handle_tRNS()
1410 png_ptr->num_trans = 0; in png_handle_tRNS()
1414 png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, in png_handle_tRNS()
1415 &(png_ptr->trans_values)); in png_handle_tRNS()
1421 png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_bKGD() argument
1428 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_bKGD()
1429 png_error(png_ptr, "Missing IHDR before bKGD"); in png_handle_bKGD()
1430 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_bKGD()
1432 png_warning(png_ptr, "Invalid bKGD after IDAT"); in png_handle_bKGD()
1433 png_crc_finish(png_ptr, length); in png_handle_bKGD()
1436 else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && in png_handle_bKGD()
1437 !(png_ptr->mode & PNG_HAVE_PLTE)) in png_handle_bKGD()
1439 png_warning(png_ptr, "Missing PLTE before bKGD"); in png_handle_bKGD()
1440 png_crc_finish(png_ptr, length); in png_handle_bKGD()
1445 png_warning(png_ptr, "Duplicate bKGD chunk"); in png_handle_bKGD()
1446 png_crc_finish(png_ptr, length); in png_handle_bKGD()
1450 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_handle_bKGD()
1452 else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) in png_handle_bKGD()
1459 png_warning(png_ptr, "Incorrect bKGD chunk length"); in png_handle_bKGD()
1460 png_crc_finish(png_ptr, length); in png_handle_bKGD()
1464 png_crc_read(png_ptr, buf, truelen); in png_handle_bKGD()
1465 if (png_crc_finish(png_ptr, 0)) in png_handle_bKGD()
1472 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_handle_bKGD()
1474 png_ptr->background.index = buf[0]; in png_handle_bKGD()
1479 png_warning(png_ptr, "Incorrect bKGD chunk index value"); in png_handle_bKGD()
1482 png_ptr->background.red = in png_handle_bKGD()
1483 (png_uint_16)png_ptr->palette[buf[0]].red; in png_handle_bKGD()
1484 png_ptr->background.green = in png_handle_bKGD()
1485 (png_uint_16)png_ptr->palette[buf[0]].green; in png_handle_bKGD()
1486 png_ptr->background.blue = in png_handle_bKGD()
1487 (png_uint_16)png_ptr->palette[buf[0]].blue; in png_handle_bKGD()
1490 else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ in png_handle_bKGD()
1492 png_ptr->background.red = in png_handle_bKGD()
1493 png_ptr->background.green = in png_handle_bKGD()
1494 png_ptr->background.blue = in png_handle_bKGD()
1495 png_ptr->background.gray = png_get_uint_16(buf); in png_handle_bKGD()
1499 png_ptr->background.red = png_get_uint_16(buf); in png_handle_bKGD()
1500 png_ptr->background.green = png_get_uint_16(buf + 2); in png_handle_bKGD()
1501 png_ptr->background.blue = png_get_uint_16(buf + 4); in png_handle_bKGD()
1504 png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); in png_handle_bKGD()
1510 png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_hIST() argument
1517 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_hIST()
1518 png_error(png_ptr, "Missing IHDR before hIST"); in png_handle_hIST()
1519 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_hIST()
1521 png_warning(png_ptr, "Invalid hIST after IDAT"); in png_handle_hIST()
1522 png_crc_finish(png_ptr, length); in png_handle_hIST()
1525 else if (!(png_ptr->mode & PNG_HAVE_PLTE)) in png_handle_hIST()
1527 png_warning(png_ptr, "Missing PLTE before hIST"); in png_handle_hIST()
1528 png_crc_finish(png_ptr, length); in png_handle_hIST()
1533 png_warning(png_ptr, "Duplicate hIST chunk"); in png_handle_hIST()
1534 png_crc_finish(png_ptr, length); in png_handle_hIST()
1539 if (num != (unsigned int) png_ptr->num_palette || num > in png_handle_hIST()
1542 png_warning(png_ptr, "Incorrect hIST chunk length"); in png_handle_hIST()
1543 png_crc_finish(png_ptr, length); in png_handle_hIST()
1551 png_crc_read(png_ptr, buf, 2); in png_handle_hIST()
1555 if (png_crc_finish(png_ptr, 0)) in png_handle_hIST()
1558 png_set_hIST(png_ptr, info_ptr, readbuf); in png_handle_hIST()
1564 png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_pHYs() argument
1572 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_pHYs()
1573 png_error(png_ptr, "Missing IHDR before pHYs"); in png_handle_pHYs()
1574 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_pHYs()
1576 png_warning(png_ptr, "Invalid pHYs after IDAT"); in png_handle_pHYs()
1577 png_crc_finish(png_ptr, length); in png_handle_pHYs()
1582 png_warning(png_ptr, "Duplicate pHYs chunk"); in png_handle_pHYs()
1583 png_crc_finish(png_ptr, length); in png_handle_pHYs()
1589 png_warning(png_ptr, "Incorrect pHYs chunk length"); in png_handle_pHYs()
1590 png_crc_finish(png_ptr, length); in png_handle_pHYs()
1594 png_crc_read(png_ptr, buf, 9); in png_handle_pHYs()
1595 if (png_crc_finish(png_ptr, 0)) in png_handle_pHYs()
1601 png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); in png_handle_pHYs()
1607 png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_oFFs() argument
1615 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_oFFs()
1616 png_error(png_ptr, "Missing IHDR before oFFs"); in png_handle_oFFs()
1617 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_oFFs()
1619 png_warning(png_ptr, "Invalid oFFs after IDAT"); in png_handle_oFFs()
1620 png_crc_finish(png_ptr, length); in png_handle_oFFs()
1625 png_warning(png_ptr, "Duplicate oFFs chunk"); in png_handle_oFFs()
1626 png_crc_finish(png_ptr, length); in png_handle_oFFs()
1632 png_warning(png_ptr, "Incorrect oFFs chunk length"); in png_handle_oFFs()
1633 png_crc_finish(png_ptr, length); in png_handle_oFFs()
1637 png_crc_read(png_ptr, buf, 9); in png_handle_oFFs()
1638 if (png_crc_finish(png_ptr, 0)) in png_handle_oFFs()
1644 png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); in png_handle_oFFs()
1651 png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_pCAL() argument
1662 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_pCAL()
1663 png_error(png_ptr, "Missing IHDR before pCAL"); in png_handle_pCAL()
1664 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_pCAL()
1666 png_warning(png_ptr, "Invalid pCAL after IDAT"); in png_handle_pCAL()
1667 png_crc_finish(png_ptr, length); in png_handle_pCAL()
1672 png_warning(png_ptr, "Duplicate pCAL chunk"); in png_handle_pCAL()
1673 png_crc_finish(png_ptr, length); in png_handle_pCAL()
1679 png_free(png_ptr, png_ptr->chunkdata); in png_handle_pCAL()
1680 png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); in png_handle_pCAL()
1681 if (png_ptr->chunkdata == NULL) in png_handle_pCAL()
1683 png_warning(png_ptr, "No memory for pCAL purpose."); in png_handle_pCAL()
1687 png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); in png_handle_pCAL()
1689 if (png_crc_finish(png_ptr, 0)) in png_handle_pCAL()
1691 png_free(png_ptr, png_ptr->chunkdata); in png_handle_pCAL()
1692 png_ptr->chunkdata = NULL; in png_handle_pCAL()
1696 png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */ in png_handle_pCAL()
1699 for (buf = png_ptr->chunkdata; *buf; buf++) in png_handle_pCAL()
1702 endptr = png_ptr->chunkdata + slength; in png_handle_pCAL()
1708 png_warning(png_ptr, "Invalid pCAL data"); in png_handle_pCAL()
1709 png_free(png_ptr, png_ptr->chunkdata); in png_handle_pCAL()
1710 png_ptr->chunkdata = NULL; in png_handle_pCAL()
1729 png_warning(png_ptr, "Invalid pCAL parameters for equation type"); in png_handle_pCAL()
1730 png_free(png_ptr, png_ptr->chunkdata); in png_handle_pCAL()
1731 png_ptr->chunkdata = NULL; in png_handle_pCAL()
1736 png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); in png_handle_pCAL()
1743 params = (png_charpp)png_malloc_warn(png_ptr, in png_handle_pCAL()
1747 png_free(png_ptr, png_ptr->chunkdata); in png_handle_pCAL()
1748 png_ptr->chunkdata = NULL; in png_handle_pCAL()
1749 png_warning(png_ptr, "No memory for pCAL params."); in png_handle_pCAL()
1765 png_warning(png_ptr, "Invalid pCAL data"); in png_handle_pCAL()
1766 png_free(png_ptr, png_ptr->chunkdata); in png_handle_pCAL()
1767 png_ptr->chunkdata = NULL; in png_handle_pCAL()
1768 png_free(png_ptr, params); in png_handle_pCAL()
1773 png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams, in png_handle_pCAL()
1776 png_free(png_ptr, png_ptr->chunkdata); in png_handle_pCAL()
1777 png_ptr->chunkdata = NULL; in png_handle_pCAL()
1778 png_free(png_ptr, params); in png_handle_pCAL()
1785 png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_sCAL() argument
1800 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_sCAL()
1801 png_error(png_ptr, "Missing IHDR before sCAL"); in png_handle_sCAL()
1802 else if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_sCAL()
1804 png_warning(png_ptr, "Invalid sCAL after IDAT"); in png_handle_sCAL()
1805 png_crc_finish(png_ptr, length); in png_handle_sCAL()
1810 png_warning(png_ptr, "Duplicate sCAL chunk"); in png_handle_sCAL()
1811 png_crc_finish(png_ptr, length); in png_handle_sCAL()
1817 png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); in png_handle_sCAL()
1818 if (png_ptr->chunkdata == NULL) in png_handle_sCAL()
1820 png_warning(png_ptr, "Out of memory while processing sCAL chunk"); in png_handle_sCAL()
1821 png_crc_finish(png_ptr, length); in png_handle_sCAL()
1825 png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); in png_handle_sCAL()
1827 if (png_crc_finish(png_ptr, 0)) in png_handle_sCAL()
1829 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sCAL()
1830 png_ptr->chunkdata = NULL; in png_handle_sCAL()
1834 png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */ in png_handle_sCAL()
1836 ep = png_ptr->chunkdata + 1; /* Skip unit byte */ in png_handle_sCAL()
1839 width = png_strtod(png_ptr, ep, &vp); in png_handle_sCAL()
1842 png_warning(png_ptr, "malformed width string in sCAL chunk"); in png_handle_sCAL()
1843 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sCAL()
1844 png_ptr->chunkdata = NULL; in png_handle_sCAL()
1849 swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); in png_handle_sCAL()
1852 png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); in png_handle_sCAL()
1853 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sCAL()
1854 png_ptr->chunkdata = NULL; in png_handle_sCAL()
1861 for (ep = png_ptr->chunkdata; *ep; ep++) in png_handle_sCAL()
1865 if (png_ptr->chunkdata + slength < ep) in png_handle_sCAL()
1867 png_warning(png_ptr, "Truncated sCAL chunk"); in png_handle_sCAL()
1869 png_free(png_ptr, swidth); in png_handle_sCAL()
1871 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sCAL()
1872 png_ptr->chunkdata = NULL; in png_handle_sCAL()
1877 height = png_strtod(png_ptr, ep, &vp); in png_handle_sCAL()
1880 png_warning(png_ptr, "malformed height string in sCAL chunk"); in png_handle_sCAL()
1881 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sCAL()
1882 png_ptr->chunkdata = NULL; in png_handle_sCAL()
1884 png_free(png_ptr, swidth); in png_handle_sCAL()
1890 sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); in png_handle_sCAL()
1893 png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); in png_handle_sCAL()
1894 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sCAL()
1895 png_ptr->chunkdata = NULL; in png_handle_sCAL()
1897 png_free(png_ptr, swidth); in png_handle_sCAL()
1905 if (png_ptr->chunkdata + slength < ep in png_handle_sCAL()
1911 png_warning(png_ptr, "Invalid sCAL data"); in png_handle_sCAL()
1912 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sCAL()
1913 png_ptr->chunkdata = NULL; in png_handle_sCAL()
1915 png_free(png_ptr, swidth); in png_handle_sCAL()
1916 png_free(png_ptr, sheight); in png_handle_sCAL()
1923 png_set_sCAL(png_ptr, info_ptr, png_ptr->chunkdata[0], width, height); in png_handle_sCAL()
1926 png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0], swidth, sheight); in png_handle_sCAL()
1930 png_free(png_ptr, png_ptr->chunkdata); in png_handle_sCAL()
1931 png_ptr->chunkdata = NULL; in png_handle_sCAL()
1933 png_free(png_ptr, swidth); in png_handle_sCAL()
1934 png_free(png_ptr, sheight); in png_handle_sCAL()
1941 png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_tIME() argument
1948 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_tIME()
1949 png_error(png_ptr, "Out of place tIME chunk"); in png_handle_tIME()
1952 png_warning(png_ptr, "Duplicate tIME chunk"); in png_handle_tIME()
1953 png_crc_finish(png_ptr, length); in png_handle_tIME()
1957 if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_tIME()
1958 png_ptr->mode |= PNG_AFTER_IDAT; in png_handle_tIME()
1962 png_warning(png_ptr, "Incorrect tIME chunk length"); in png_handle_tIME()
1963 png_crc_finish(png_ptr, length); in png_handle_tIME()
1967 png_crc_read(png_ptr, buf, 7); in png_handle_tIME()
1968 if (png_crc_finish(png_ptr, 0)) in png_handle_tIME()
1978 png_set_tIME(png_ptr, info_ptr, &mod_time); in png_handle_tIME()
1985 png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_tEXt() argument
1997 if (png_ptr->user_chunk_cache_max != 0) in png_handle_tEXt()
1999 if (png_ptr->user_chunk_cache_max == 1) in png_handle_tEXt()
2001 png_crc_finish(png_ptr, length); in png_handle_tEXt()
2004 if (--png_ptr->user_chunk_cache_max == 1) in png_handle_tEXt()
2006 png_warning(png_ptr, "No space in chunk cache for tEXt"); in png_handle_tEXt()
2007 png_crc_finish(png_ptr, length); in png_handle_tEXt()
2013 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_tEXt()
2014 png_error(png_ptr, "Missing IHDR before tEXt"); in png_handle_tEXt()
2016 if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_tEXt()
2017 png_ptr->mode |= PNG_AFTER_IDAT; in png_handle_tEXt()
2022 png_warning(png_ptr, "tEXt chunk too large to fit in memory"); in png_handle_tEXt()
2028 png_free(png_ptr, png_ptr->chunkdata); in png_handle_tEXt()
2030 png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); in png_handle_tEXt()
2031 if (png_ptr->chunkdata == NULL) in png_handle_tEXt()
2033 png_warning(png_ptr, "No memory to process text chunk."); in png_handle_tEXt()
2037 png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); in png_handle_tEXt()
2039 if (png_crc_finish(png_ptr, skip)) in png_handle_tEXt()
2041 png_free(png_ptr, png_ptr->chunkdata); in png_handle_tEXt()
2042 png_ptr->chunkdata = NULL; in png_handle_tEXt()
2046 key = png_ptr->chunkdata; in png_handle_tEXt()
2056 text_ptr = (png_textp)png_malloc_warn(png_ptr, in png_handle_tEXt()
2060 png_warning(png_ptr, "Not enough memory to process text chunk."); in png_handle_tEXt()
2061 png_free(png_ptr, png_ptr->chunkdata); in png_handle_tEXt()
2062 png_ptr->chunkdata = NULL; in png_handle_tEXt()
2075 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); in png_handle_tEXt()
2077 png_free(png_ptr, png_ptr->chunkdata); in png_handle_tEXt()
2078 png_ptr->chunkdata = NULL; in png_handle_tEXt()
2079 png_free(png_ptr, text_ptr); in png_handle_tEXt()
2081 png_warning(png_ptr, "Insufficient memory to process text chunk."); in png_handle_tEXt()
2088 png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_zTXt() argument
2099 if (png_ptr->user_chunk_cache_max != 0) in png_handle_zTXt()
2101 if (png_ptr->user_chunk_cache_max == 1) in png_handle_zTXt()
2103 png_crc_finish(png_ptr, length); in png_handle_zTXt()
2106 if (--png_ptr->user_chunk_cache_max == 1) in png_handle_zTXt()
2108 png_warning(png_ptr, "No space in chunk cache for zTXt"); in png_handle_zTXt()
2109 png_crc_finish(png_ptr, length); in png_handle_zTXt()
2115 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_zTXt()
2116 png_error(png_ptr, "Missing IHDR before zTXt"); in png_handle_zTXt()
2118 if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_zTXt()
2119 png_ptr->mode |= PNG_AFTER_IDAT; in png_handle_zTXt()
2126 png_warning(png_ptr, "zTXt chunk too large to fit in memory"); in png_handle_zTXt()
2127 png_crc_finish(png_ptr, length); in png_handle_zTXt()
2132 png_free(png_ptr, png_ptr->chunkdata); in png_handle_zTXt()
2133 png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); in png_handle_zTXt()
2134 if (png_ptr->chunkdata == NULL) in png_handle_zTXt()
2136 png_warning(png_ptr, "Out of memory processing zTXt chunk."); in png_handle_zTXt()
2140 png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); in png_handle_zTXt()
2141 if (png_crc_finish(png_ptr, 0)) in png_handle_zTXt()
2143 png_free(png_ptr, png_ptr->chunkdata); in png_handle_zTXt()
2144 png_ptr->chunkdata = NULL; in png_handle_zTXt()
2148 png_ptr->chunkdata[slength] = 0x00; in png_handle_zTXt()
2150 for (text = png_ptr->chunkdata; *text; text++) in png_handle_zTXt()
2154 if (text >= png_ptr->chunkdata + slength - 2) in png_handle_zTXt()
2156 png_warning(png_ptr, "Truncated zTXt chunk"); in png_handle_zTXt()
2157 png_free(png_ptr, png_ptr->chunkdata); in png_handle_zTXt()
2158 png_ptr->chunkdata = NULL; in png_handle_zTXt()
2166 png_warning(png_ptr, "Unknown compression type in zTXt chunk"); in png_handle_zTXt()
2171 prefix_len = text - png_ptr->chunkdata; in png_handle_zTXt()
2173 png_decompress_chunk(png_ptr, comp_type, in png_handle_zTXt()
2176 text_ptr = (png_textp)png_malloc_warn(png_ptr, in png_handle_zTXt()
2180 png_warning(png_ptr, "Not enough memory to process zTXt chunk."); in png_handle_zTXt()
2181 png_free(png_ptr, png_ptr->chunkdata); in png_handle_zTXt()
2182 png_ptr->chunkdata = NULL; in png_handle_zTXt()
2186 text_ptr->key = png_ptr->chunkdata; in png_handle_zTXt()
2192 text_ptr->text = png_ptr->chunkdata + prefix_len; in png_handle_zTXt()
2195 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); in png_handle_zTXt()
2197 png_free(png_ptr, text_ptr); in png_handle_zTXt()
2198 png_free(png_ptr, png_ptr->chunkdata); in png_handle_zTXt()
2199 png_ptr->chunkdata = NULL; in png_handle_zTXt()
2201 png_error(png_ptr, "Insufficient memory to store zTXt chunk."); in png_handle_zTXt()
2208 png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_iTXt() argument
2220 if (png_ptr->user_chunk_cache_max != 0) in png_handle_iTXt()
2222 if (png_ptr->user_chunk_cache_max == 1) in png_handle_iTXt()
2224 png_crc_finish(png_ptr, length); in png_handle_iTXt()
2227 if (--png_ptr->user_chunk_cache_max == 1) in png_handle_iTXt()
2229 png_warning(png_ptr, "No space in chunk cache for iTXt"); in png_handle_iTXt()
2230 png_crc_finish(png_ptr, length); in png_handle_iTXt()
2236 if (!(png_ptr->mode & PNG_HAVE_IHDR)) in png_handle_iTXt()
2237 png_error(png_ptr, "Missing IHDR before iTXt"); in png_handle_iTXt()
2239 if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_iTXt()
2240 png_ptr->mode |= PNG_AFTER_IDAT; in png_handle_iTXt()
2247 png_warning(png_ptr, "iTXt chunk too large to fit in memory"); in png_handle_iTXt()
2248 png_crc_finish(png_ptr, length); in png_handle_iTXt()
2253 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iTXt()
2254 png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); in png_handle_iTXt()
2255 if (png_ptr->chunkdata == NULL) in png_handle_iTXt()
2257 png_warning(png_ptr, "No memory to process iTXt chunk."); in png_handle_iTXt()
2261 png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); in png_handle_iTXt()
2262 if (png_crc_finish(png_ptr, 0)) in png_handle_iTXt()
2264 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iTXt()
2265 png_ptr->chunkdata = NULL; in png_handle_iTXt()
2269 png_ptr->chunkdata[slength] = 0x00; in png_handle_iTXt()
2271 for (lang = png_ptr->chunkdata; *lang; lang++) in png_handle_iTXt()
2280 if (lang >= png_ptr->chunkdata + slength - 3) in png_handle_iTXt()
2282 png_warning(png_ptr, "Truncated iTXt chunk"); in png_handle_iTXt()
2283 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iTXt()
2284 png_ptr->chunkdata = NULL; in png_handle_iTXt()
2297 if (lang_key >= png_ptr->chunkdata + slength) in png_handle_iTXt()
2299 png_warning(png_ptr, "Truncated iTXt chunk"); in png_handle_iTXt()
2300 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iTXt()
2301 png_ptr->chunkdata = NULL; in png_handle_iTXt()
2308 if (text >= png_ptr->chunkdata + slength) in png_handle_iTXt()
2310 png_warning(png_ptr, "Malformed iTXt chunk"); in png_handle_iTXt()
2311 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iTXt()
2312 png_ptr->chunkdata = NULL; in png_handle_iTXt()
2316 prefix_len = text - png_ptr->chunkdata; in png_handle_iTXt()
2318 key=png_ptr->chunkdata; in png_handle_iTXt()
2320 png_decompress_chunk(png_ptr, comp_type, in png_handle_iTXt()
2323 data_len = png_strlen(png_ptr->chunkdata + prefix_len); in png_handle_iTXt()
2324 text_ptr = (png_textp)png_malloc_warn(png_ptr, in png_handle_iTXt()
2328 png_warning(png_ptr, "Not enough memory to process iTXt chunk."); in png_handle_iTXt()
2329 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iTXt()
2330 png_ptr->chunkdata = NULL; in png_handle_iTXt()
2334 text_ptr->lang_key = png_ptr->chunkdata + (lang_key - key); in png_handle_iTXt()
2335 text_ptr->lang = png_ptr->chunkdata + (lang - key); in png_handle_iTXt()
2338 text_ptr->key = png_ptr->chunkdata; in png_handle_iTXt()
2339 text_ptr->text = png_ptr->chunkdata + prefix_len; in png_handle_iTXt()
2341 ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); in png_handle_iTXt()
2343 png_free(png_ptr, text_ptr); in png_handle_iTXt()
2344 png_free(png_ptr, png_ptr->chunkdata); in png_handle_iTXt()
2345 png_ptr->chunkdata = NULL; in png_handle_iTXt()
2347 png_error(png_ptr, "Insufficient memory to store iTXt chunk."); in png_handle_iTXt()
2357 png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) in png_handle_unknown() argument
2364 if (png_ptr->user_chunk_cache_max != 0) in png_handle_unknown()
2366 if (png_ptr->user_chunk_cache_max == 1) in png_handle_unknown()
2368 png_crc_finish(png_ptr, length); in png_handle_unknown()
2371 if (--png_ptr->user_chunk_cache_max == 1) in png_handle_unknown()
2373 png_warning(png_ptr, "No space in chunk cache for unknown chunk"); in png_handle_unknown()
2374 png_crc_finish(png_ptr, length); in png_handle_unknown()
2380 if (png_ptr->mode & PNG_HAVE_IDAT) in png_handle_unknown()
2385 if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* Not an IDAT */ in png_handle_unknown()
2386 png_ptr->mode |= PNG_AFTER_IDAT; in png_handle_unknown()
2389 if (!(png_ptr->chunk_name[0] & 0x20)) in png_handle_unknown()
2392 if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != in png_handle_unknown()
2395 && png_ptr->read_user_chunk_fn == NULL in png_handle_unknown()
2399 png_chunk_error(png_ptr, "unknown critical chunk"); in png_handle_unknown()
2403 if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) in png_handle_unknown()
2405 || (png_ptr->read_user_chunk_fn != NULL) in png_handle_unknown()
2412 png_warning(png_ptr, "unknown chunk too large to fit in memory"); in png_handle_unknown()
2417 png_memcpy((png_charp)png_ptr->unknown_chunk.name, in png_handle_unknown()
2418 (png_charp)png_ptr->chunk_name, in png_handle_unknown()
2419 png_sizeof(png_ptr->unknown_chunk.name)); in png_handle_unknown()
2420 png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1] in png_handle_unknown()
2422 png_ptr->unknown_chunk.size = (png_size_t)length; in png_handle_unknown()
2424 png_ptr->unknown_chunk.data = NULL; in png_handle_unknown()
2427 png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); in png_handle_unknown()
2428 png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); in png_handle_unknown()
2431 if (png_ptr->read_user_chunk_fn != NULL) in png_handle_unknown()
2435 ret = (*(png_ptr->read_user_chunk_fn)) in png_handle_unknown()
2436 (png_ptr, &png_ptr->unknown_chunk); in png_handle_unknown()
2438 png_chunk_error(png_ptr, "error in user chunk"); in png_handle_unknown()
2441 if (!(png_ptr->chunk_name[0] & 0x20)) in png_handle_unknown()
2443 if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != in png_handle_unknown()
2446 png_chunk_error(png_ptr, "unknown critical chunk"); in png_handle_unknown()
2447 png_set_unknown_chunks(png_ptr, info_ptr, in png_handle_unknown()
2448 &png_ptr->unknown_chunk, 1); in png_handle_unknown()
2453 png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); in png_handle_unknown()
2454 png_free(png_ptr, png_ptr->unknown_chunk.data); in png_handle_unknown()
2455 png_ptr->unknown_chunk.data = NULL; in png_handle_unknown()
2461 png_crc_finish(png_ptr, skip); in png_handle_unknown()
2477 png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) in png_check_chunk_name() argument
2483 png_chunk_error(png_ptr, "invalid chunk type"); in png_check_chunk_name()
2499 png_combine_row(png_structp png_ptr, png_bytep row, int mask) in png_combine_row() argument
2504 png_memcpy(row, png_ptr->row_buf + 1, in png_combine_row()
2505 PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width)); in png_combine_row()
2509 switch (png_ptr->row_info.pixel_depth) in png_combine_row()
2513 png_bytep sp = png_ptr->row_buf + 1; in png_combine_row()
2519 png_uint_32 row_width = png_ptr->width; in png_combine_row()
2522 if (png_ptr->transformations & PNG_PACKSWAP) in png_combine_row()
2567 png_bytep sp = png_ptr->row_buf + 1; in png_combine_row()
2573 png_uint_32 row_width = png_ptr->width; in png_combine_row()
2577 if (png_ptr->transformations & PNG_PACKSWAP) in png_combine_row()
2619 png_bytep sp = png_ptr->row_buf + 1; in png_combine_row()
2625 png_uint_32 row_width = png_ptr->width; in png_combine_row()
2629 if (png_ptr->transformations & PNG_PACKSWAP) in png_combine_row()
2670 png_bytep sp = png_ptr->row_buf + 1; in png_combine_row()
2672 png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); in png_combine_row()
2674 png_uint_32 row_width = png_ptr->width; in png_combine_row()
2705 png_do_read_interlace(png_structp png_ptr) in png_do_read_interlace() argument
2707 png_row_infop row_info = &(png_ptr->row_info); in png_do_read_interlace()
2708 png_bytep row = png_ptr->row_buf + 1; in png_do_read_interlace()
2709 int pass = png_ptr->pass; in png_do_read_interlace()
2710 png_uint_32 transformations = png_ptr->transformations; in png_do_read_interlace()
2926 png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, in png_read_filter_row() argument
2930 png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter); in png_read_filter_row()
3042 png_warning(png_ptr, "Ignoring bad adaptive filter type"); in png_read_filter_row()
3050 png_read_finish_row(png_structp png_ptr) in png_read_finish_row() argument
3069 png_ptr->row_number++; in png_read_finish_row()
3070 if (png_ptr->row_number < png_ptr->num_rows) in png_read_finish_row()
3074 if (png_ptr->interlaced) in png_read_finish_row()
3076 png_ptr->row_number = 0; in png_read_finish_row()
3077 png_memset_check(png_ptr, png_ptr->prev_row, 0, in png_read_finish_row()
3078 png_ptr->rowbytes + 1); in png_read_finish_row()
3081 png_ptr->pass++; in png_read_finish_row()
3082 if (png_ptr->pass >= 7) in png_read_finish_row()
3084 png_ptr->iwidth = (png_ptr->width + in png_read_finish_row()
3085 png_pass_inc[png_ptr->pass] - 1 - in png_read_finish_row()
3086 png_pass_start[png_ptr->pass]) / in png_read_finish_row()
3087 png_pass_inc[png_ptr->pass]; in png_read_finish_row()
3089 if (!(png_ptr->transformations & PNG_INTERLACE)) in png_read_finish_row()
3091 png_ptr->num_rows = (png_ptr->height + in png_read_finish_row()
3092 png_pass_yinc[png_ptr->pass] - 1 - in png_read_finish_row()
3093 png_pass_ystart[png_ptr->pass]) / in png_read_finish_row()
3094 png_pass_yinc[png_ptr->pass]; in png_read_finish_row()
3095 if (!(png_ptr->num_rows)) in png_read_finish_row()
3100 } while (png_ptr->iwidth == 0); in png_read_finish_row()
3102 if (png_ptr->pass < 7) in png_read_finish_row()
3107 if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) in png_read_finish_row()
3115 png_ptr->zstream.next_out = (Byte *)&extra; in png_read_finish_row()
3116 png_ptr->zstream.avail_out = (uInt)1; in png_read_finish_row()
3119 if (!(png_ptr->zstream.avail_in)) in png_read_finish_row()
3121 while (!png_ptr->idat_size) in png_read_finish_row()
3125 png_crc_finish(png_ptr, 0); in png_read_finish_row()
3127 png_read_data(png_ptr, chunk_length, 4); in png_read_finish_row()
3128 png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length); in png_read_finish_row()
3129 png_reset_crc(png_ptr); in png_read_finish_row()
3130 png_crc_read(png_ptr, png_ptr->chunk_name, 4); in png_read_finish_row()
3131 if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) in png_read_finish_row()
3132 png_error(png_ptr, "Not enough image data"); in png_read_finish_row()
3135 png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; in png_read_finish_row()
3136 png_ptr->zstream.next_in = png_ptr->zbuf; in png_read_finish_row()
3137 if (png_ptr->zbuf_size > png_ptr->idat_size) in png_read_finish_row()
3138 png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; in png_read_finish_row()
3139 png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); in png_read_finish_row()
3140 png_ptr->idat_size -= png_ptr->zstream.avail_in; in png_read_finish_row()
3142 ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); in png_read_finish_row()
3145 if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || in png_read_finish_row()
3146 png_ptr->idat_size) in png_read_finish_row()
3147 png_warning(png_ptr, "Extra compressed data."); in png_read_finish_row()
3148 png_ptr->mode |= PNG_AFTER_IDAT; in png_read_finish_row()
3149 png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; in png_read_finish_row()
3153 png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : in png_read_finish_row()
3156 if (!(png_ptr->zstream.avail_out)) in png_read_finish_row()
3158 png_warning(png_ptr, "Extra compressed data."); in png_read_finish_row()
3159 png_ptr->mode |= PNG_AFTER_IDAT; in png_read_finish_row()
3160 png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; in png_read_finish_row()
3165 png_ptr->zstream.avail_out = 0; in png_read_finish_row()
3168 if (png_ptr->idat_size || png_ptr->zstream.avail_in) in png_read_finish_row()
3169 png_warning(png_ptr, "Extra compression data."); in png_read_finish_row()
3171 inflateReset(&png_ptr->zstream); in png_read_finish_row()
3173 png_ptr->mode |= PNG_AFTER_IDAT; in png_read_finish_row()
3178 png_read_start_row(png_structp png_ptr) in png_read_start_row() argument
3200 png_ptr->zstream.avail_in = 0; in png_read_start_row()
3201 png_init_read_transformations(png_ptr); in png_read_start_row()
3203 if (png_ptr->interlaced) in png_read_start_row()
3205 if (!(png_ptr->transformations & PNG_INTERLACE)) in png_read_start_row()
3206 png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - in png_read_start_row()
3209 png_ptr->num_rows = png_ptr->height; in png_read_start_row()
3211 png_ptr->iwidth = (png_ptr->width + in png_read_start_row()
3212 png_pass_inc[png_ptr->pass] - 1 - in png_read_start_row()
3213 png_pass_start[png_ptr->pass]) / in png_read_start_row()
3214 png_pass_inc[png_ptr->pass]; in png_read_start_row()
3219 png_ptr->num_rows = png_ptr->height; in png_read_start_row()
3220 png_ptr->iwidth = png_ptr->width; in png_read_start_row()
3222 max_pixel_depth = png_ptr->pixel_depth; in png_read_start_row()
3225 if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) in png_read_start_row()
3230 if (png_ptr->transformations & PNG_EXPAND) in png_read_start_row()
3232 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_read_start_row()
3234 if (png_ptr->num_trans) in png_read_start_row()
3239 else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) in png_read_start_row()
3243 if (png_ptr->num_trans) in png_read_start_row()
3246 else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) in png_read_start_row()
3248 if (png_ptr->num_trans) in png_read_start_row()
3258 if (png_ptr->transformations & (PNG_FILLER)) in png_read_start_row()
3260 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_read_start_row()
3262 else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) in png_read_start_row()
3269 else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) in png_read_start_row()
3280 if (png_ptr->transformations & PNG_GRAY_TO_RGB) in png_read_start_row()
3284 (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || in png_read_start_row()
3287 (png_ptr->transformations & (PNG_FILLER)) || in png_read_start_row()
3289 png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) in png_read_start_row()
3300 if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) in png_read_start_row()
3305 else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) in png_read_start_row()
3315 if (png_ptr->transformations & PNG_USER_TRANSFORM) in png_read_start_row()
3317 int user_pixel_depth = png_ptr->user_transform_depth* in png_read_start_row()
3318 png_ptr->user_transform_channels; in png_read_start_row()
3327 row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); in png_read_start_row()
3335 png_error(png_ptr, "This image requires a row greater than 64KB"); in png_read_start_row()
3338 if (row_bytes + 64 > png_ptr->old_big_row_buf_size) in png_read_start_row()
3340 png_free(png_ptr, png_ptr->big_row_buf); in png_read_start_row()
3341 if (png_ptr->interlaced) in png_read_start_row()
3342 png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, in png_read_start_row()
3345 png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, in png_read_start_row()
3347 png_ptr->old_big_row_buf_size = row_bytes + 64; in png_read_start_row()
3350 png_ptr->row_buf = png_ptr->big_row_buf + 32; in png_read_start_row()
3351 png_ptr->old_big_row_buf_size = row_bytes + 64; in png_read_start_row()
3356 png_error(png_ptr, "This image requires a row greater than 64KB"); in png_read_start_row()
3359 png_error(png_ptr, "Row has too many bytes to allocate in memory."); in png_read_start_row()
3361 if (row_bytes + 1 > png_ptr->old_prev_row_size) in png_read_start_row()
3363 png_free(png_ptr, png_ptr->prev_row); in png_read_start_row()
3364 png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( in png_read_start_row()
3366 png_memset_check(png_ptr, png_ptr->prev_row, 0, row_bytes + 1); in png_read_start_row()
3367 png_ptr->old_prev_row_size = row_bytes + 1; in png_read_start_row()
3370 png_ptr->rowbytes = row_bytes; in png_read_start_row()
3372 png_debug1(3, "width = %lu,", png_ptr->width); in png_read_start_row()
3373 png_debug1(3, "height = %lu,", png_ptr->height); in png_read_start_row()
3374 png_debug1(3, "iwidth = %lu,", png_ptr->iwidth); in png_read_start_row()
3375 png_debug1(3, "num_rows = %lu,", png_ptr->num_rows); in png_read_start_row()
3376 png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes); in png_read_start_row()
3378 PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1); in png_read_start_row()
3380 png_ptr->flags |= PNG_FLAG_ROW_INIT; in png_read_start_row()