[gnome-builder] unsaved-files: be safe when freeing an unsaved file



commit 1385d6731e2566d5ba42316b20cebf655b6d475b
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Apr 11 12:25:07 2015 +0200

    unsaved-files: be safe when freeing an unsaved file
    
    If the object has been copied the file and fd may be null and we
    should not call unlink and close

 libide/ide-unsaved-files.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/libide/ide-unsaved-files.c b/libide/ide-unsaved-files.c
index fb5f923..d5056b5 100644
--- a/libide/ide-unsaved-files.c
+++ b/libide/ide-unsaved-files.c
@@ -75,9 +75,13 @@ unsaved_file_free (gpointer data)
     {
       g_object_unref (uf->file);
       g_bytes_unref (uf->content);
-      g_unlink (uf->temp_path);
-      g_free (uf->temp_path);
-      g_close (uf->temp_fd, NULL);
+      if (uf->temp_path)
+        {
+           g_unlink (uf->temp_path);
+           g_free (uf->temp_path);
+        }
+      if (uf->temp_fd != 0)
+        g_close (uf->temp_fd, NULL);
       g_slice_free (UnsavedFile, uf);
     }
 }


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