| Index: third_party/libpng/pngpread.c
|
| diff --git a/third_party/libpng/pngpread.c b/third_party/libpng/pngpread.c
|
| index d066944cae14eb6225e9aa2049ea18f3c935edaf..5af209d4d533be5c16288161829c4379379c8f84 100644
|
| --- a/third_party/libpng/pngpread.c
|
| +++ b/third_party/libpng/pngpread.c
|
| @@ -71,30 +71,6 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
| break;
|
| }
|
|
|
| -#ifdef PNG_READ_tEXt_SUPPORTED
|
| - case PNG_READ_tEXt_MODE:
|
| - {
|
| - png_push_read_tEXt(png_ptr, info_ptr);
|
| - break;
|
| - }
|
| -
|
| -#endif
|
| -#ifdef PNG_READ_zTXt_SUPPORTED
|
| - case PNG_READ_zTXt_MODE:
|
| - {
|
| - png_push_read_zTXt(png_ptr, info_ptr);
|
| - break;
|
| - }
|
| -
|
| -#endif
|
| -#ifdef PNG_READ_iTXt_SUPPORTED
|
| - case PNG_READ_iTXt_MODE:
|
| - {
|
| - png_push_read_iTXt(png_ptr, info_ptr);
|
| - break;
|
| - }
|
| -
|
| -#endif
|
| case PNG_SKIP_MODE:
|
| {
|
| png_push_crc_finish(png_ptr);
|
| @@ -529,7 +505,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
| return;
|
| }
|
|
|
| - png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
|
| + png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
|
| }
|
|
|
| #endif
|
| @@ -542,7 +518,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
| return;
|
| }
|
|
|
| - png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
|
| + png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
|
| }
|
|
|
| #endif
|
| @@ -555,7 +531,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
| return;
|
| }
|
|
|
| - png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
|
| + png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
|
| }
|
|
|
| #endif
|
| @@ -566,7 +542,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
| png_push_save_buffer(png_ptr);
|
| return;
|
| }
|
| - png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
|
| + png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
|
| }
|
|
|
| png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
| @@ -1201,515 +1177,6 @@ png_read_push_finish_row(png_structp png_ptr)
|
| #endif /* PNG_READ_INTERLACING_SUPPORTED */
|
| }
|
|
|
| -#ifdef PNG_READ_tEXt_SUPPORTED
|
| -void /* PRIVATE */
|
| -png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
| - length)
|
| -{
|
| - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
| - {
|
| - png_error(png_ptr, "Out of place tEXt");
|
| - info_ptr = info_ptr; /* To quiet some compiler warnings */
|
| - }
|
| -
|
| -#ifdef PNG_MAX_MALLOC_64K
|
| - png_ptr->skip_length = 0; /* This may not be necessary */
|
| -
|
| - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
|
| - {
|
| - png_warning(png_ptr, "tEXt chunk too large to fit in memory");
|
| - png_ptr->skip_length = length - (png_uint_32)65535L;
|
| - length = (png_uint_32)65535L;
|
| - }
|
| -#endif
|
| -
|
| - png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
| - (png_uint_32)(length + 1));
|
| - png_ptr->current_text[length] = '\0';
|
| - png_ptr->current_text_ptr = png_ptr->current_text;
|
| - png_ptr->current_text_size = (png_size_t)length;
|
| - png_ptr->current_text_left = (png_size_t)length;
|
| - png_ptr->process_mode = PNG_READ_tEXt_MODE;
|
| -}
|
| -
|
| -void /* PRIVATE */
|
| -png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
| -{
|
| - if (png_ptr->buffer_size && png_ptr->current_text_left)
|
| - {
|
| - png_size_t text_size;
|
| -
|
| - if (png_ptr->buffer_size < png_ptr->current_text_left)
|
| - text_size = png_ptr->buffer_size;
|
| -
|
| - else
|
| - text_size = png_ptr->current_text_left;
|
| -
|
| - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
|
| - png_ptr->current_text_left -= text_size;
|
| - png_ptr->current_text_ptr += text_size;
|
| - }
|
| - if (!(png_ptr->current_text_left))
|
| - {
|
| - png_textp text_ptr;
|
| - png_charp text;
|
| - png_charp key;
|
| - int ret;
|
| -
|
| - if (png_ptr->buffer_size < 4)
|
| - {
|
| - png_push_save_buffer(png_ptr);
|
| - return;
|
| - }
|
| -
|
| - png_push_crc_finish(png_ptr);
|
| -
|
| -#ifdef PNG_MAX_MALLOC_64K
|
| - if (png_ptr->skip_length)
|
| - return;
|
| -#endif
|
| -
|
| - key = png_ptr->current_text;
|
| -
|
| - for (text = key; *text; text++)
|
| - /* Empty loop */ ;
|
| -
|
| - if (text < key + png_ptr->current_text_size)
|
| - text++;
|
| -
|
| - text_ptr = (png_textp)png_malloc(png_ptr,
|
| - (png_uint_32)png_sizeof(png_text));
|
| - text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
|
| - text_ptr->key = key;
|
| -#ifdef PNG_iTXt_SUPPORTED
|
| - text_ptr->lang = NULL;
|
| - text_ptr->lang_key = NULL;
|
| -#endif
|
| - text_ptr->text = text;
|
| -
|
| - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
|
| -
|
| - png_free(png_ptr, key);
|
| - png_free(png_ptr, text_ptr);
|
| - png_ptr->current_text = NULL;
|
| -
|
| - if (ret)
|
| - png_warning(png_ptr, "Insufficient memory to store text chunk.");
|
| - }
|
| -}
|
| -#endif
|
| -
|
| -#ifdef PNG_READ_zTXt_SUPPORTED
|
| -void /* PRIVATE */
|
| -png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
| - length)
|
| -{
|
| - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
| - {
|
| - png_error(png_ptr, "Out of place zTXt");
|
| - info_ptr = info_ptr; /* To quiet some compiler warnings */
|
| - }
|
| -
|
| -#ifdef PNG_MAX_MALLOC_64K
|
| - /* We can't handle zTXt chunks > 64K, since we don't have enough space
|
| - * to be able to store the uncompressed data. Actually, the threshold
|
| - * is probably around 32K, but it isn't as definite as 64K is.
|
| - */
|
| - if (length > (png_uint_32)65535L)
|
| - {
|
| - png_warning(png_ptr, "zTXt chunk too large to fit in memory");
|
| - png_push_crc_skip(png_ptr, length);
|
| - return;
|
| - }
|
| -#endif
|
| -
|
| - png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
| - (png_uint_32)(length + 1));
|
| - png_ptr->current_text[length] = '\0';
|
| - png_ptr->current_text_ptr = png_ptr->current_text;
|
| - png_ptr->current_text_size = (png_size_t)length;
|
| - png_ptr->current_text_left = (png_size_t)length;
|
| - png_ptr->process_mode = PNG_READ_zTXt_MODE;
|
| -}
|
| -
|
| -void /* PRIVATE */
|
| -png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
| -{
|
| - if (png_ptr->buffer_size && png_ptr->current_text_left)
|
| - {
|
| - png_size_t text_size;
|
| -
|
| - if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left)
|
| - text_size = png_ptr->buffer_size;
|
| -
|
| - else
|
| - text_size = png_ptr->current_text_left;
|
| -
|
| - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
|
| - png_ptr->current_text_left -= text_size;
|
| - png_ptr->current_text_ptr += text_size;
|
| - }
|
| - if (!(png_ptr->current_text_left))
|
| - {
|
| - png_textp text_ptr;
|
| - png_charp text;
|
| - png_charp key;
|
| - int ret;
|
| - png_size_t text_size, key_size;
|
| -
|
| - if (png_ptr->buffer_size < 4)
|
| - {
|
| - png_push_save_buffer(png_ptr);
|
| - return;
|
| - }
|
| -
|
| - png_push_crc_finish(png_ptr);
|
| -
|
| - key = png_ptr->current_text;
|
| -
|
| - for (text = key; *text; text++)
|
| - /* Empty loop */ ;
|
| -
|
| - /* zTXt can't have zero text */
|
| - if (text >= key + png_ptr->current_text_size)
|
| - {
|
| - png_ptr->current_text = NULL;
|
| - png_free(png_ptr, key);
|
| - return;
|
| - }
|
| -
|
| - text++;
|
| -
|
| - if (*text != PNG_TEXT_COMPRESSION_zTXt) /* Check compression byte */
|
| - {
|
| - png_ptr->current_text = NULL;
|
| - png_free(png_ptr, key);
|
| - return;
|
| - }
|
| -
|
| - text++;
|
| -
|
| - png_ptr->zstream.next_in = (png_bytep )text;
|
| - png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -
|
| - (text - key));
|
| - png_ptr->zstream.next_out = png_ptr->zbuf;
|
| - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
| -
|
| - key_size = text - key;
|
| - text_size = 0;
|
| - text = NULL;
|
| - ret = Z_STREAM_END;
|
| -
|
| - while (png_ptr->zstream.avail_in)
|
| - {
|
| - ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
|
| - if (ret != Z_OK && ret != Z_STREAM_END)
|
| - {
|
| - inflateReset(&png_ptr->zstream);
|
| - png_ptr->zstream.avail_in = 0;
|
| - png_ptr->current_text = NULL;
|
| - png_free(png_ptr, key);
|
| - png_free(png_ptr, text);
|
| - return;
|
| - }
|
| - if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END)
|
| - {
|
| - if (text == NULL)
|
| - {
|
| - text = (png_charp)png_malloc(png_ptr,
|
| - (png_uint_32)(png_ptr->zbuf_size
|
| - - png_ptr->zstream.avail_out + key_size + 1));
|
| -
|
| - png_memcpy(text + key_size, png_ptr->zbuf,
|
| - png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
| -
|
| - png_memcpy(text, key, key_size);
|
| -
|
| - text_size = key_size + png_ptr->zbuf_size -
|
| - png_ptr->zstream.avail_out;
|
| -
|
| - *(text + text_size) = '\0';
|
| - }
|
| - else
|
| - {
|
| - png_charp tmp;
|
| -
|
| - tmp = text;
|
| - text = (png_charp)png_malloc(png_ptr, text_size +
|
| - (png_uint_32)(png_ptr->zbuf_size
|
| - - png_ptr->zstream.avail_out + 1));
|
| -
|
| - png_memcpy(text, tmp, text_size);
|
| - png_free(png_ptr, tmp);
|
| -
|
| - png_memcpy(text + text_size, png_ptr->zbuf,
|
| - png_ptr->zbuf_size - png_ptr->zstream.avail_out);
|
| -
|
| - text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
|
| - *(text + text_size) = '\0';
|
| - }
|
| - if (ret != Z_STREAM_END)
|
| - {
|
| - png_ptr->zstream.next_out = png_ptr->zbuf;
|
| - png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
| - }
|
| - }
|
| - else
|
| - {
|
| - break;
|
| - }
|
| -
|
| - if (ret == Z_STREAM_END)
|
| - break;
|
| - }
|
| -
|
| - inflateReset(&png_ptr->zstream);
|
| - png_ptr->zstream.avail_in = 0;
|
| -
|
| - if (ret != Z_STREAM_END)
|
| - {
|
| - png_ptr->current_text = NULL;
|
| - png_free(png_ptr, key);
|
| - png_free(png_ptr, text);
|
| - return;
|
| - }
|
| -
|
| - png_ptr->current_text = NULL;
|
| - png_free(png_ptr, key);
|
| - key = text;
|
| - text += key_size;
|
| -
|
| - text_ptr = (png_textp)png_malloc(png_ptr,
|
| - (png_uint_32)png_sizeof(png_text));
|
| - text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
|
| - text_ptr->key = key;
|
| -#ifdef PNG_iTXt_SUPPORTED
|
| - text_ptr->lang = NULL;
|
| - text_ptr->lang_key = NULL;
|
| -#endif
|
| - text_ptr->text = text;
|
| -
|
| - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
|
| -
|
| - png_free(png_ptr, key);
|
| - png_free(png_ptr, text_ptr);
|
| -
|
| - if (ret)
|
| - png_warning(png_ptr, "Insufficient memory to store text chunk.");
|
| - }
|
| -}
|
| -#endif
|
| -
|
| -#ifdef PNG_READ_iTXt_SUPPORTED
|
| -void /* PRIVATE */
|
| -png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
| - length)
|
| -{
|
| - if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
| - {
|
| - png_error(png_ptr, "Out of place iTXt");
|
| - info_ptr = info_ptr; /* To quiet some compiler warnings */
|
| - }
|
| -
|
| -#ifdef PNG_MAX_MALLOC_64K
|
| - png_ptr->skip_length = 0; /* This may not be necessary */
|
| -
|
| - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
|
| - {
|
| - png_warning(png_ptr, "iTXt chunk too large to fit in memory");
|
| - png_ptr->skip_length = length - (png_uint_32)65535L;
|
| - length = (png_uint_32)65535L;
|
| - }
|
| -#endif
|
| -
|
| - png_ptr->current_text = (png_charp)png_malloc(png_ptr,
|
| - (png_uint_32)(length + 1));
|
| - png_ptr->current_text[length] = '\0';
|
| - png_ptr->current_text_ptr = png_ptr->current_text;
|
| - png_ptr->current_text_size = (png_size_t)length;
|
| - png_ptr->current_text_left = (png_size_t)length;
|
| - png_ptr->process_mode = PNG_READ_iTXt_MODE;
|
| -}
|
| -
|
| -void /* PRIVATE */
|
| -png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
| -{
|
| -
|
| - if (png_ptr->buffer_size && png_ptr->current_text_left)
|
| - {
|
| - png_size_t text_size;
|
| -
|
| - if (png_ptr->buffer_size < png_ptr->current_text_left)
|
| - text_size = png_ptr->buffer_size;
|
| -
|
| - else
|
| - text_size = png_ptr->current_text_left;
|
| -
|
| - png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
|
| - png_ptr->current_text_left -= text_size;
|
| - png_ptr->current_text_ptr += text_size;
|
| - }
|
| - if (!(png_ptr->current_text_left))
|
| - {
|
| - png_textp text_ptr;
|
| - png_charp key;
|
| - int comp_flag;
|
| - png_charp lang;
|
| - png_charp lang_key;
|
| - png_charp text;
|
| - int ret;
|
| -
|
| - if (png_ptr->buffer_size < 4)
|
| - {
|
| - png_push_save_buffer(png_ptr);
|
| - return;
|
| - }
|
| -
|
| - png_push_crc_finish(png_ptr);
|
| -
|
| -#ifdef PNG_MAX_MALLOC_64K
|
| - if (png_ptr->skip_length)
|
| - return;
|
| -#endif
|
| -
|
| - key = png_ptr->current_text;
|
| -
|
| - for (lang = key; *lang; lang++)
|
| - /* Empty loop */ ;
|
| -
|
| - if (lang < key + png_ptr->current_text_size - 3)
|
| - lang++;
|
| -
|
| - comp_flag = *lang++;
|
| - lang++; /* Skip comp_type, always zero */
|
| -
|
| - for (lang_key = lang; *lang_key; lang_key++)
|
| - /* Empty loop */ ;
|
| -
|
| - lang_key++; /* Skip NUL separator */
|
| -
|
| - text=lang_key;
|
| -
|
| - if (lang_key < key + png_ptr->current_text_size - 1)
|
| - {
|
| - for (; *text; text++)
|
| - /* Empty loop */ ;
|
| - }
|
| -
|
| - if (text < key + png_ptr->current_text_size)
|
| - text++;
|
| -
|
| - text_ptr = (png_textp)png_malloc(png_ptr,
|
| - (png_uint_32)png_sizeof(png_text));
|
| -
|
| - text_ptr->compression = comp_flag + 2;
|
| - text_ptr->key = key;
|
| - text_ptr->lang = lang;
|
| - text_ptr->lang_key = lang_key;
|
| - text_ptr->text = text;
|
| - text_ptr->text_length = 0;
|
| - text_ptr->itxt_length = png_strlen(text);
|
| -
|
| - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
|
| -
|
| - png_ptr->current_text = NULL;
|
| -
|
| - png_free(png_ptr, text_ptr);
|
| - if (ret)
|
| - png_warning(png_ptr, "Insufficient memory to store iTXt chunk.");
|
| - }
|
| -}
|
| -#endif
|
| -
|
| -/* This function is called when we haven't found a handler for this
|
| - * chunk. If there isn't a problem with the chunk itself (ie a bad chunk
|
| - * name or a critical chunk), the chunk is (currently) silently ignored.
|
| - */
|
| -void /* PRIVATE */
|
| -png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
| - length)
|
| -{
|
| - png_uint_32 skip = 0;
|
| -
|
| - if (!(png_ptr->chunk_name[0] & 0x20))
|
| - {
|
| -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
| - if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
| - PNG_HANDLE_CHUNK_ALWAYS
|
| -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
| - && png_ptr->read_user_chunk_fn == NULL
|
| -#endif
|
| - )
|
| -#endif
|
| - png_chunk_error(png_ptr, "unknown critical chunk");
|
| -
|
| - info_ptr = info_ptr; /* To quiet some compiler warnings */
|
| - }
|
| -
|
| -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
| - if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
|
| - {
|
| -#ifdef PNG_MAX_MALLOC_64K
|
| - if (length > (png_uint_32)65535L)
|
| - {
|
| - png_warning(png_ptr, "unknown chunk too large to fit in memory");
|
| - skip = length - (png_uint_32)65535L;
|
| - length = (png_uint_32)65535L;
|
| - }
|
| -#endif
|
| - png_memcpy((png_charp)png_ptr->unknown_chunk.name,
|
| - (png_charp)png_ptr->chunk_name,
|
| - png_sizeof(png_ptr->unknown_chunk.name));
|
| - png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name) - 1]
|
| - = '\0';
|
| -
|
| - png_ptr->unknown_chunk.size = (png_size_t)length;
|
| -
|
| - if (length == 0)
|
| - png_ptr->unknown_chunk.data = NULL;
|
| -
|
| - else
|
| - {
|
| - png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr,
|
| - (png_uint_32)length);
|
| - png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
|
| - }
|
| -
|
| -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
| - if (png_ptr->read_user_chunk_fn != NULL)
|
| - {
|
| - /* Callback to user unknown chunk handler */
|
| - int ret;
|
| - ret = (*(png_ptr->read_user_chunk_fn))
|
| - (png_ptr, &png_ptr->unknown_chunk);
|
| -
|
| - if (ret < 0)
|
| - png_chunk_error(png_ptr, "error in user chunk");
|
| -
|
| - if (ret == 0)
|
| - {
|
| - if (!(png_ptr->chunk_name[0] & 0x20))
|
| - if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
| - PNG_HANDLE_CHUNK_ALWAYS)
|
| - png_chunk_error(png_ptr, "unknown critical chunk");
|
| - png_set_unknown_chunks(png_ptr, info_ptr,
|
| - &png_ptr->unknown_chunk, 1);
|
| - }
|
| - }
|
| -
|
| - else
|
| -#endif
|
| - png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
|
| - png_free(png_ptr, png_ptr->unknown_chunk.data);
|
| - png_ptr->unknown_chunk.data = NULL;
|
| - }
|
| -
|
| - else
|
| -#endif
|
| - skip=length;
|
| - png_push_crc_skip(png_ptr, skip);
|
| -}
|
| -
|
| void /* PRIVATE */
|
| png_push_have_info(png_structp png_ptr, png_infop info_ptr)
|
| {
|
|
|