mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-01-08 17:20:12 +01:00
linux: Fix possible double-close on exit
Fix double-close on exit. If we created a GIOChannel from the file descriptor, then g_io_channel_shutdown() will close that file descriptor as well. Close the channel first, so that the file descriptor is only closed manually if we didn't manage to create a GIOChannel from it. https://gitlab.freedesktop.org/upower/upower/issues/60
This commit is contained in:
parent
0e51436b4b
commit
054cb3f4b8
1 changed files with 3 additions and 2 deletions
|
|
@ -286,12 +286,13 @@ up_input_finalize (GObject *object)
|
|||
g_return_if_fail (input->priv != NULL);
|
||||
|
||||
g_clear_object (&input->priv->daemon);
|
||||
if (input->priv->eventfp >= 0)
|
||||
close (input->priv->eventfp);
|
||||
if (input->priv->channel) {
|
||||
g_io_channel_shutdown (input->priv->channel, FALSE, NULL);
|
||||
input->priv->eventfp = -1;
|
||||
g_io_channel_unref (input->priv->channel);
|
||||
}
|
||||
if (input->priv->eventfp >= 0)
|
||||
close (input->priv->eventfp);
|
||||
G_OBJECT_CLASS (up_input_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue