[glib/glib-2-48] glocalfileoutputstream: Fix an FD leak in an error path



commit cbb030d90a62b1792834206fcc92895df3b4873e
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu May 15 10:30:38 2014 +0100

    glocalfileoutputstream: Fix an FD leak in an error path
    
    If a backup file is created, opened successfully, then fstat() on it
    fails (perhaps due to another process deleting it in the mean time?),
    the FD will be leaked.
    
    Coverity issue: #1159485
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730187

 gio/glocalfileoutputstream.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c
index b8fd45c..b4f348e 100644
--- a/gio/glocalfileoutputstream.c
+++ b/gio/glocalfileoutputstream.c
@@ -953,6 +953,7 @@ handle_overwrite_open (const char    *filename,
                                G_IO_ERROR_CANT_CREATE_BACKUP,
                                _("Backup file creation failed"));
          g_unlink (backup_filename);
+         (void) g_close (bfd, NULL);
          g_free (backup_filename);
          goto err_out;
        }


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