From 74b297a9a50e19c97a71bc6e317bc8e4bdf2a0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 26 Nov 2019 20:36:44 +0100 Subject: [PATCH 042/181] virtual-image: Also unref the object when closing a the stream While a stream is closed when completely unreffed, the other way around isn't true, so always unref the object. --- libfprint/drivers/virtual-image.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libfprint/drivers/virtual-image.c b/libfprint/drivers/virtual-image.c index 6fdd3db..612863d 100644 --- a/libfprint/drivers/virtual-image.c +++ b/libfprint/drivers/virtual-image.c @@ -81,7 +81,7 @@ recv_image_img_recv_cb (GObject *source_object, self = FPI_DEVICE_VIRTUAL_IMAGE (user_data); g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL); - self->connection = NULL; + g_clear_object (&self->connection); return; } @@ -118,7 +118,7 @@ recv_image_hdr_recv_cb (GObject *source_object, self = FPI_DEVICE_VIRTUAL_IMAGE (user_data); g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL); - self->connection = NULL; + g_clear_object (&self->connection); return; } @@ -127,7 +127,7 @@ recv_image_hdr_recv_cb (GObject *source_object, { g_warning ("Image header suggests an unrealistically large image, disconnecting client."); g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL); - self->connection = NULL; + g_clear_object (&self->connection); } if (self->recv_img_hdr[0] < 0 || self->recv_img_hdr[1] < 0) @@ -148,7 +148,7 @@ recv_image_hdr_recv_cb (GObject *source_object, default: /* disconnect client, it didn't play fair */ g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL); - self->connection = NULL; + g_clear_object (&self->connection); } /* And, listen for more images from the same client. */ @@ -206,6 +206,7 @@ new_connection_cb (GObject *source_object, GAsyncResult *res, gpointer user_data if (dev->connection) { g_io_stream_close (G_IO_STREAM (connection), NULL, NULL); + g_object_unref (connection); return; } -- 2.24.1