This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit 5352caecb3d9ce7c2eecf66281d9b1b636a4c6a5
Author: Kim Woelders <[email protected]>
AuthorDate: Sat Feb 4 09:55:45 2023 +0100

    PNG saver: Avoid potential clobber warning
    
    Also remove some unnecessary png cleanup function calls.
    All is done by png_destroy_write_struct(), which was even called twice.
---
 src/modules/loaders/loader_png.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/modules/loaders/loader_png.c b/src/modules/loaders/loader_png.c
index 8c6b79d..6dc743f 100644
--- a/src/modules/loaders/loader_png.c
+++ b/src/modules/loaders/loader_png.c
@@ -591,6 +591,10 @@ _load(ImlibImage * im, int load_data)
    return rc;
 }
 
+typedef struct {
+   png_bytep           data;
+} misc_data_t;
+
 static int
 _save(ImlibImage * im)
 {
@@ -598,9 +602,10 @@ _save(ImlibImage * im)
    FILE               *f = im->fi->fp;
    png_structp         png_ptr;
    png_infop           info_ptr;
+   misc_data_t         misc;
    uint32_t           *ptr;
    int                 x, y, j, interlace;
-   png_bytep           row_ptr, data;
+   png_bytep           row_ptr;
    png_color_8         sig_bit;
    ImlibImageTag      *tag;
    int                 quality = 75, compression = 3;
@@ -609,18 +614,18 @@ _save(ImlibImage * im)
 
    rc = LOAD_FAIL;
    info_ptr = NULL;
-   data = ""
+   misc.data = ""
 
    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
    if (!png_ptr)
-      goto quit;
+      return LOAD_FAIL;
 
    info_ptr = png_create_info_struct(png_ptr);
    if (!info_ptr)
       goto quit;
 
    if (setjmp(png_jmpbuf(png_ptr)))
-      goto quit;
+      QUIT_WITH_RC(LOAD_FAIL);
 
    /* check whether we should use interlacing */
    interlace = PNG_INTERLACE_NONE;
@@ -649,7 +654,7 @@ _save(ImlibImage * im)
         png_set_IHDR(png_ptr, info_ptr, im->w, im->h, 8, PNG_COLOR_TYPE_RGB,
                      interlace, PNG_COMPRESSION_TYPE_BASE,
                      PNG_FILTER_TYPE_BASE);
-        data = "" * 3 * sizeof(png_byte));
+        misc.data = "" * 3 * sizeof(png_byte));
      }
    sig_bit.red = 8;
    sig_bit.green = 8;
@@ -720,11 +725,11 @@ _save(ImlibImage * im)
                     {
                        uint32_t            pixel = ptr[x];
 
-                       data[j++] = PIXEL_R(pixel);
-                       data[j++] = PIXEL_G(pixel);
-                       data[j++] = PIXEL_B(pixel);
+                       misc.data[j++] = PIXEL_R(pixel);
+                       misc.data[j++] = PIXEL_G(pixel);
+                       misc.data[j++] = PIXEL_B(pixel);
                     }
-                  row_ptr = (png_bytep) data;
+                  row_ptr = misc.data;
                }
              png_write_rows(png_ptr, &row_ptr, 1);
 
@@ -738,13 +743,9 @@ _save(ImlibImage * im)
    rc = LOAD_SUCCESS;
 
  quit:
-   free(data);
+   free(misc.data);
    png_write_end(png_ptr, info_ptr);
-   png_destroy_write_struct(&png_ptr, (png_infopp) & info_ptr);
-   if (info_ptr)
-      png_destroy_info_struct(png_ptr, (png_infopp) & info_ptr);
-   if (png_ptr)
-      png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
+   png_destroy_write_struct(&png_ptr, &info_ptr);
 
    return rc;
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to