Skip to content

Commit 20deda7

Browse files
authored
Unreference PolkitAuthorizationResult and PolkitAuthority structs only when not needed (#551)
1 parent 04f08fa commit 20deda7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/DBus/DBusBridge.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,11 @@ namespace usbguard
492492
USBGUARD_LOG(Trace) << "Connecting with Polkit authority...";
493493
PolkitAuthority* const authority = polkit_authority_get_sync(/*cancellable=*/ NULL, &error);
494494

495-
if (! authority || error) {
495+
if (! authority) {
496496
USBGUARD_LOG(Trace) << "Failed to connect to Polkit authority: " << formatGError(error) << ".";
497497
*authErrorCode = G_DBUS_ERROR_AUTH_FAILED;
498498
*authErrorMessage = "Failed to connect to Polkit authority";
499499
g_error_free(error);
500-
g_object_unref(authority);
501500
g_object_unref(subject);
502501
return false;
503502
}
@@ -528,12 +527,11 @@ namespace usbguard
528527
/*cancellable=*/ NULL,
529528
&error);
530529

531-
if (! result || error) {
530+
if (! result) {
532531
USBGUARD_LOG(Trace) << "Failed to check back with Polkit for authoriation: " << formatGError(error) << ".";
533532
*authErrorCode = G_DBUS_ERROR_AUTH_FAILED;
534533
*authErrorMessage = "Failed to check back with Polkit for authoriation.";
535534
g_error_free(error);
536-
g_object_unref(result);
537535
g_object_unref(details);
538536
g_object_unref(authority);
539537
g_object_unref(subject);

0 commit comments

Comments
 (0)