diff -Nru grafx2-2.6/debian/changelog grafx2-2.6/debian/changelog --- grafx2-2.6/debian/changelog 2019-01-10 15:51:38.000000000 +0000 +++ grafx2-2.6/debian/changelog 2019-01-21 12:44:37.000000000 +0000 @@ -1,3 +1,9 @@ +grafx2 (2.6-2) unstable; urgency=medium + + * Patch src/fileformats to fix png saving. + + -- Gürkan Myczko Mon, 21 Jan 2019 13:44:37 +0100 + grafx2 (2.6-1) unstable; urgency=medium * New upstream version. (Closes: #918725) diff -Nru grafx2-2.6/debian/patches/fix-png-save-segfault grafx2-2.6/debian/patches/fix-png-save-segfault --- grafx2-2.6/debian/patches/fix-png-save-segfault 1970-01-01 00:00:00.000000000 +0000 +++ grafx2-2.6/debian/patches/fix-png-save-segfault 2019-01-21 12:44:37.000000000 +0000 @@ -0,0 +1,80 @@ +Description: + TODO: Put a short summary on the line above and replace this paragraph + with a longer explanation of this change. Complete the meta-information + with other relevant fields (see below for details). To make it easier, the + information below has been extracted from the changelog. Adjust it or drop + it. + . + grafx2 (2.6-2) unstable; urgency=medium + . + * Patch src/fileformats to fix png saving. +Author: Gürkan Myczko + +--- +The information above should follow the Patch Tagging Guidelines, please +checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here +are templates for supplementary fields that you might want to add: + +Origin: , +Bug: +Bug-Debian: https://bugs.debian.org/ +Bug-Ubuntu: https://launchpad.net/bugs/ +Forwarded: +Reviewed-By: +Last-Update: 2019-01-21 + +--- grafx2-2.6.orig/src/fileformats.c ++++ grafx2-2.6/src/fileformats.c +@@ -6798,6 +6798,7 @@ void Save_PNG_Sub(T_IO_Context * context + 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 + { + 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 + + 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 + + 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); + } + + diff -Nru grafx2-2.6/debian/patches/series grafx2-2.6/debian/patches/series --- grafx2-2.6/debian/patches/series 2018-12-10 08:06:17.000000000 +0000 +++ grafx2-2.6/debian/patches/series 2019-01-21 12:44:37.000000000 +0000 @@ -1 +1,2 @@ sdl2-api +fix-png-save-segfault