From 681bd1ed2add52660feab01f2934f722adc664e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 12 Feb 2020 05:53:36 +0100 Subject: [PATCH] device: Fix leaked matched print on identify When starting an identify operation we allocate a gallery of prints from the gallery, although if we match one of them we get that back in the finish callback but with a further reference added. So, in order to clean it up, use an auto-pointer or we'd end up in leaking it, and the address sanitizer was catching this in our tests already: Indirect leak of 12020 byte(s) in 5 object(s) allocated from: #0 0x7fe8bc638ce6 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dce6) #1 0x7fe8bc37ffd0 in g_malloc0 ../../glib/glib/gmem.c:132 #2 0x55d100635c01 in load_from_file ../src/file_storage.c:159 #3 0x55d100635c01 in file_storage_print_data_load ../src/file_storage.c:182 #4 0x55d10063e950 in fprint_device_verify_start ../src/device.c:882 #5 0x55d10064036b in dbus_glib_marshal_fprint_device_VOID__STRING_POINTER src/device-dbus-glue.h:96 #6 0x7fe8bc50f6f5 (/usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2+0xd6f5) --- src/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index a9080d3..5237bd6 100644 --- a/src/device.c +++ b/src/device.c @@ -767,11 +767,11 @@ static void verify_cb(FpDevice *dev, GAsyncResult *res, void *user_data) static void identify_cb(FpDevice *dev, GAsyncResult *res, void *user_data) { g_autoptr(GError) error = NULL; + g_autoptr(FpPrint) match = NULL; FprintDevice *rdev = user_data; FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev); const char *name; gboolean success; - FpPrint *match; success = fp_device_identify_finish (dev, res, &match, NULL, &error); g_assert (!!success == !error);