-
Notifications
You must be signed in to change notification settings - Fork 150
Unreference PolkitAuthorizationResult and PolkitAuthority structs if needed #551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Cropi ,
for review of this pull request I asked myself two questions:
-
Can function
polkit_authority_get_syncreturnNULL?
I found the answer in filepolkit-v.121/src/polkit/polkitauthority.c: Yes, it can. -
Can function
g_object_unrefbe called withNULL, safely?
After some digging, the answer is: No, it cannot.
With those two answers I agree that this pull request is moving the code into the right direction and fixes a real problem 👍 . I would suggest to also drop the second || error from ! authority || error for both consistency and readability, and then I'd consider it "perfect". What do you think?
Best, Sebastian
|
@Cropi PS: For the CI failure with Ubuntu 21.10, I believe the main point was to cover the most recent Ubuntu, more recent than GitHub CI's |
Thanks for the review. I definitely agree that we should change the |
…y when not needed
I am not against it but usually @radosroka is the one who creates the releases. |
|
@radosroka any chance or objections? |
I can create release later today. |
|
@radosroka cool! Thank you! |
Release is out there: https://github.com/USBGuard/usbguard/releases/tag/usbguard-1.1.2 |
|
@radosroka thank you! Bumped to 1.1.2 in Gentoo as well now. |
polkit_authority_get_sync()fails, then it will return null, so there is no need to free it withg_object_unref().polkit_authority_check_authorization_sync(). The documentation says the following: "APolkitAuthorizationResultis returned or NULL if error is set. Free with g_object_unref()."I came across this issue when SElinux did not allow usbguard-dbus to perform the mentioned actions. Thus, usbguard tried to free memory, which was not even allocated.
[1] https://www.freedesktop.org/software/polkit/docs/latest/PolkitAuthority.html