From 889073219468be569ec42056a1971537bcabdc21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 6 Feb 2020 14:18:16 +0100 Subject: [PATCH] device: Don't leak the user on claim error while deleting prints When using the delete method we check if the device was claimed, if this fails because the device is already in use we return an error, but we don't free the user. While this could be fixed by just a further g_free call, let's just remove remove the other manual free calls, and use an auto-pointer instead for this function. --- src/device.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/device.c b/src/device.c index 107eac3..a9080d3 100644 --- a/src/device.c +++ b/src/device.c @@ -1349,7 +1349,8 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev, { FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev); g_autoptr(GError) error = NULL; - char *user, *sender; + g_autofree char *user = NULL; + char *sender; gboolean opened; g_warning ("The API user should be updated to use DeleteEnrolledFingers2 method!"); @@ -1368,7 +1369,6 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev, } if (_fprint_device_check_polkit_for_action (rdev, context, "net.reactivated.fprint.device.enroll", &error) == FALSE) { - g_free (user); dbus_g_method_return_error (context, error); return; } @@ -1397,8 +1397,6 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev, if (!opened && fp_device_has_storage (priv->dev)) fp_device_close_sync (priv->dev, NULL, NULL); - g_free (user); - dbus_g_method_return(context); }