After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 730187 - glocalfileoutputstream: Fix an FD leak in an error path
glocalfileoutputstream: Fix an FD leak in an error path
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-05-15 11:46 UTC by Philip Withnall
Modified: 2016-06-16 18:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
glocalfileoutputstream: Fix an FD leak in an error path (1.02 KB, patch)
2014-05-15 11:46 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2014-05-15 11:46:20 UTC
Patch attached.
Comment 1 Philip Withnall 2014-05-15 11:46:22 UTC
Created attachment 276596 [details] [review]
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
Comment 2 Allison Karlitskaya (desrt) 2016-06-16 18:36:50 UTC
Review of attachment 276596 [details] [review]:

...note below, but feel free to handle that in a separate patch.

::: gio/glocalfileoutputstream.c
@@ +954,3 @@
                                _("Backup file creation failed"));
 	  g_unlink (backup_filename);
+	  (void) g_close (bfd, NULL);

Drop the (void) thing, but otherwise looks good.  Thanks!
Comment 3 Philip Withnall 2016-06-16 18:41:16 UTC
Pushed. I'll push a follow-up to remove all (void) the (void) random (void) void (void) casts.

Attachment 276596 [details] pushed as 16d6744 - glocalfileoutputstream: Fix an FD leak in an error path
Comment 4 Colin Walters 2016-06-16 18:46:15 UTC
(In reply to Allison Lortie (desrt) from comment #2)

> Drop the (void) thing, but otherwise looks good.  Thanks!

I often use that because at least Coverity complains if a return value is checked in some places but not others.
Comment 5 Philip Withnall 2016-06-16 18:49:09 UTC
(In reply to Colin Walters from comment #4)
> (In reply to Allison Lortie (desrt) from comment #2)
> 
> > Drop the (void) thing, but otherwise looks good.  Thanks!
> 
> I often use that because at least Coverity complains if a return value is
> checked in some places but not others.

Hmm, good point. I've already pushed a commit to remove them (fadd00c7085fd0dc2722c974260768540cc6f8b9), but we can revert it if the next Coverity run gets upset. Alternatively, we mark those Coverity issues as ignored, which should persist through to future runs.