[glib/gio-thumbnail-sizes: 5/14] glocalfileoutputstream: Do not double-close an fd on unlink error




commit 75fe934d0362fe21b3bcec8cf7fb4e5e70c903d8
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Fri Sep 16 15:11:47 2022 +0200

    glocalfileoutputstream: Do not double-close an fd on unlink error
    
    In case we fail unlinking a file we could close again an FD that has
    been already just closed. So avoid this by unsetting it when closing.
    
    Coverity CID: #1474462

 gio/glocalfileoutputstream.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c
index 400934be1f..3ce987fba8 100644
--- a/gio/glocalfileoutputstream.c
+++ b/gio/glocalfileoutputstream.c
@@ -1194,7 +1194,8 @@ handle_overwrite_open (const char    *filename,
   if (replace_destination_set)
     {
       g_close (fd, NULL);
-      
+      fd = -1;
+
       if (g_unlink (filename) != 0)
        {
           errsv = errno;


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