png: allocate data before sigsetjmp()
authorBenjamin Otte <otte@redhat.com>
Fri, 22 Oct 2021 21:51:26 +0000 (23:51 +0200)
committerBenjamin Otte <otte@redhat.com>
Fri, 22 Oct 2021 22:03:51 +0000 (00:03 +0200)
Makes the static analyzer not trip up when trying to analyze memory
leaks.

gdk/loaders/gdkpng.c

index 11ed7e4ef95d442a5f048e961b2f99add40d5335..4d50dfbf838807b31807a1ba13d6e9a29436c6fc 100644 (file)
@@ -385,6 +385,8 @@ gdk_save_png (GdkTexture *texture)
       return NULL;
     }
 
+  memtex = gdk_memory_texture_from_texture (texture, format);
+
   if (sigsetjmp (png_jmpbuf (png), 1))
     {
       g_object_unref (memtex);
@@ -393,8 +395,6 @@ gdk_save_png (GdkTexture *texture)
       return NULL;
     }
 
-  memtex = gdk_memory_texture_from_texture (texture, format);
-
   png_set_write_fn (png, &io, png_write_func, png_flush_func);
 
   png_set_IHDR (png, info, width, height, depth,