<commit_before>/*
 * GLSL Sandbox shader player
 */

/*
 * This program is distributer under the 2-clause BSD license.
 * See at the end of this file for details.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
#include <string.h>
#include <errno.h>

#include <png.h>

#include "pngio.h"

/* Default libpng limit is 1000000x1000000 pixels.
 * This is a bit high for the usage in this case.
 * We declare smaller limits. */
#define PNG_MAX_WIDTH 65536u
#define PNG_MAX_HEIGHT PNG_MAX_WIDTH

void
read_png_file(const char *fname, unsigned char **img_data, int *img_width, int *img_height, int *img_channels)
{
  png_uint_32 rowbytes;
  png_byte *image_data;
  png_bytep *row_pointers;
  png_structp png_ptr;
  png_infop info_ptr;
  png_byte header[8];
  png_byte color_type;
  png_byte bit_depth;<commit_msg>pngio: disable setjmp.h header inclusion check<commit_after>/*
 * GLSL Sandbox shader player
 */

/*
 * This program is distributer under the 2-clause BSD license.
 * See at the end of this file for details.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
#include <string.h>
#include <errno.h>

/* libpng 1.2 (shipped in Ubuntu 16.04 LTS for example) checks that
 * <setjmp.h> is not included before <png.h>.  This check is disabled
 * here. See:
 * https://sourceforge.net/p/libpng/code/ci/libpng-1.2.55-signed/tree/pngconf.h#l362
 * This check was removed in:
 * https://sourceforge.net/p/libpng/code/ci/6c2e919c7eb736d230581a4c925fa67bd901fcf8 */
#define PNG_SKIP_SETJMP_CHECK 1
#include <png.h>

#include "pngio.h"

/* Default libpng limit is 1000000x1000000 pixels.
 * This is a bit high for the usage in this case.
 * We declare smaller limits. */
#define PNG_MAX_WIDTH 65536u
#define PNG_MAX_HEIGHT PNG_MAX_WIDTH

void
read_png_file(const char *fname, unsigned char **img_data, int *img_width, int *img_height, int *img_channels)
{
  png_uint_32 rowbytes;
  png_byte *image_data;
  png_bytep *row_pointers;
  png_structp png_ptr;
  png_infop info_ptr;
  png_byte header[8];
  png_byte color_type;
  png_byte bit_depth;
{'fraction_non_alphanumeric': 0.10453283996299723, 'fraction_numerical': 0.0393154486586494, 'mean_word_length': 4.4075, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4062235', 'n_tokens_mistral': 892, 'n_tokens_neox': 800, 'n_words': 233}