[gimp] plug-ins: The plugin can leak the "tif" file descriptor as written...



commit fe340c822af1cedf4377c49dcde8e04de839dc4a
Author: Liam Quin <liam fromoldbooks org>
Date:   Sun Sep 27 01:07:24 2020 +0200

    plug-ins: The plugin can leak the "tif" file descriptor as written...
    
    ... and also doesn't write out all the data, if it does a "goto out" for
    any reason. A leaked file descriptor can prevent a file from being
    renamed or deleted on Windows.
    See also #3740.
    
    Reviewer note (Jehan): this may not be the main issue as reporters were
    not writing about export failure. So there is probably another case even
    when the plug-in successfully wrote the TIFF image.

 plug-ins/file-tiff/file-tiff-save.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-save.c b/plug-ins/file-tiff/file-tiff-save.c
index 8a17bd6c9e..adc527da3d 100644
--- a/plug-ins/file-tiff/file-tiff-save.c
+++ b/plug-ins/file-tiff/file-tiff-save.c
@@ -947,7 +947,7 @@ save_image (GFile         *file,
             GimpMetadata  *metadata,
             GError       **error)
 {
-  TIFF       *tif;
+  TIFF       *tif = NULL;
   const Babl *space               = NULL;
   gboolean    status              = FALSE;
   gboolean    out_linear          = FALSE;
@@ -1133,6 +1133,9 @@ save_image (GFile         *file,
         }
     }
 
+  status = TRUE;
+
+out:
   /* close the file for good */
   if (tif)
     {
@@ -1142,9 +1145,6 @@ save_image (GFile         *file,
 
   gimp_progress_update (1.0);
 
-  status = TRUE;
-
-out:
   g_list_free (layers);
   return status;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]