device: Always free error in delete enrolled fingers

During delete enrolled fingers call, if the check-claimed control fails, and
we get an error different from FPRINT_ERROR_CLAIM_DEVICE, we would return
the error without freeing it.

While this could be fixed by just a further g_error_free call, let's just
remove all the manual free calls, and use an auto-pointer instead for this
function.
This commit is contained in:
Marco Trevisan (Treviño)
2020-01-29 22:14:36 +01:00
parent e25544a8f0
commit 49dced5566

View File

@ -1349,7 +1349,7 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev,
DBusGMethodInvocation *context) DBusGMethodInvocation *context)
{ {
FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev); FprintDevicePrivate *priv = fprint_device_get_instance_private(rdev);
GError *error = NULL; g_autoptr(GError) error = NULL;
char *user, *sender; char *user, *sender;
gboolean opened; gboolean opened;
@ -1365,14 +1365,12 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev,
&error); &error);
if (user == NULL) { if (user == NULL) {
dbus_g_method_return_error (context, error); dbus_g_method_return_error (context, error);
g_error_free (error);
return; return;
} }
if (_fprint_device_check_polkit_for_action (rdev, context, "net.reactivated.fprint.device.enroll", &error) == FALSE) { if (_fprint_device_check_polkit_for_action (rdev, context, "net.reactivated.fprint.device.enroll", &error) == FALSE) {
g_free (user); g_free (user);
dbus_g_method_return_error (context, error); dbus_g_method_return_error (context, error);
g_error_free (error);
return; return;
} }
@ -1383,7 +1381,6 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev,
return; return;
} }
g_clear_error (&error);
opened = FALSE; opened = FALSE;
} else { } else {
opened = TRUE; opened = TRUE;