I am observing a crash due to access violation in libpng (1.6.20) when calling png_write_info. I created libpng from the source (including zlib 1.2.8), and the png tests that come with the libpng source code fail without errors. I can confirm that during these tests, good png files are created.
A simple breakdown of my program (until it works) looks like this. I removed all error checks and restrictions for simplicity:
int main(int argc, char *argv[]) {
char* filename = argv[1];
png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_infop info = png_create_info_struct(png);
if (setjmp(png_jmpbuf(png)))
{
abort();
}
png_set_IHDR(
png,
info,
127, 127,
16,
PNG_COLOR_TYPE_GRAY,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT
);
FILE *fp;
errno_t error = fopen_s(&fp, filename, "wb");
png_init_io(png, fp);
png_write_info(png, info);
Thank you for your help!
codeSourcerer
source
share