On Wed 15/01/2020 12:30, Solene Rapenne wrote: > When I save a picture in png file, from gdb I get the following > backtrace. This seems to only happen with png, I tried a few others > format (xmp, gif, ico, bmp) and they work fine. > > Tried on amd64, current > > Program received signal SIGSEGV, Segmentation fault. > Save_PNG_Sub (context=0x7f7ffffd53a8, file=<optimized out>, buffer=0x0, > buffer_size=0x0) at fileformats.c:6965 > 6965 fileformats.c: No such file or directory. > (gdb) bt > #0 Save_PNG_Sub (context=0x7f7ffffd53a8, file=<optimized out>, buffer=0x0, > buffer_size=0x0) at fileformats.c:6965 > #1 0x00000e642c27bd42 in Save_PNG (context=0x7f7ffffd53a8) at > fileformats.c:6981 > #2 0x00000e642c219716 in Save_image (context=0x7f7ffffd53a8) at > loadsave.c:1121 > #3 0x00000e642c1f5739 in Save_picture (type=CONTEXT_MAIN_IMAGE) at > buttons.c:3562 > #4 0x00000e642c220dfa in Main_handler () at engine.c:1584 > #5 0x00000e642c1d1300 in main (argc=<optimized out>, argv=<optimized out>) > at main.c:1378
This issue has been addressed upstream, and a patch is available. Tested on amd64. Lets see what fcambus@ thinks of the diff below. diff --git Makefile Makefile index 73c8085fcc4..cf06742cf4f 100644 --- Makefile +++ Makefile @@ -3,6 +3,7 @@ COMMENT = bitmap paint program inspired by Deluxe Paint and Brilliance V = 2.6 +REVISION = 0 DISTNAME = grafX2-v${V} PKGNAME = grafx2-${V} EXTRACT_SUFX = .tar.bz2 diff --git patches/patch-fileformats_c patches/patch-fileformats_c new file mode 100644 index 00000000000..cb04dd0ad96 --- /dev/null +++ patches/patch-fileformats_c @@ -0,0 +1,61 @@ +$OpenBSD$ + +Fix PNG saving. Taken from +https://gitlab.com/GrafX2/grafX2/commit/119618ae14f28c28ed679905b8e1a90835fb1926 + +Index: fileformats.c +--- fileformats.c.orig ++++ fileformats.c +@@ -6798,6 +6798,7 @@ void Save_PNG_Sub(T_IO_Context * context, FILE * file, + byte cycle_data[16*6]; // Storage for color-cycling data, referenced by crng_chunk + struct PNG_memory_buffer memory_buffer; + ++ memset(&memory_buffer, 0, sizeof(memory_buffer)); + /* initialisation */ + if ((png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)) + && (info_ptr = png_create_info_struct(png_ptr))) +@@ -6806,14 +6807,10 @@ void Save_PNG_Sub(T_IO_Context * context, FILE * file, + { + if (file != NULL) + png_init_io(png_ptr, file); +- else +- { +- // to write to memory, use png_set_write_fn() instead of calling png_init_io() +- memset(&memory_buffer, 0, sizeof(memory_buffer)); ++ else // to write to memory, use png_set_write_fn() instead of calling png_init_io() + png_set_write_fn(png_ptr, &memory_buffer, PNG_memory_write, PNG_memory_flush); +- } +- +- /* en-tete */ ++ ++ /* read PNG header */ + if (!setjmp(png_jmpbuf(png_ptr))) + { + png_set_IHDR(png_ptr, info_ptr, context->Width, context->Height, +@@ -6822,8 +6819,7 @@ void Save_PNG_Sub(T_IO_Context * context, FILE * file, + + png_set_PLTE(png_ptr, info_ptr, (png_colorp)context->Palette, 256); + { +- // Commentaires texte PNG +- // Cette partie est optionnelle ++ // text chunks in PNG (optional) + png_text text_ptr[2] = { + #ifdef PNG_iTXt_SUPPORTED + {-1, "Software", "Grafx2", 6, 0, NULL, NULL}, +@@ -6960,11 +6956,14 @@ void Save_PNG_Sub(T_IO_Context * context, FILE * file, + + if (Row_pointers) + free(Row_pointers); +- if (memory_buffer.buffer) ++ if (File_error == 0 && buffer != NULL) + { + *buffer = memory_buffer.buffer; +- *buffer_size = memory_buffer.offset; ++ if (buffer_size != NULL) ++ *buffer_size = memory_buffer.offset; + } ++ else ++ free(memory_buffer.buffer); + } + +