Skip to content
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

pk-offline-update: Fix crash due to invalid g_auto declaration in switch / case #728

Merged
merged 1 commit into from
Mar 23, 2024

Conversation

sidt4
Copy link
Contributor

@sidt4 sidt4 commented Mar 22, 2024

case PK_PROGRESS_TYPE_PERCENTAGE is just a label and doesn't offer any scope as such. So, tmp_perc auto variable will be allocated in the stack, but will not be initialized to NULL for case: statements other than PK_PROGRESS_TYPE_PERCENTAGE, causing GLib to consider the tmp_perc garbage value as a valid memory address allocated via g_malloc(), triggering an invalid free() causing the crash.

Rather than adding a scope {} within case, and causing a huge noise in git diff, we just move the declaration to an upper scope.

…tch / case

'case PK_PROGRESS_TYPE_PERCENTAGE' is just a label and doesn't offer
any scope as such. So, 'tmp_perc' auto variable will be allocated in
the stack, but will not be initialized to 'NULL' for 'case:'
statements other than 'PK_PROGRESS_TYPE_PERCENTAGE', causing GLib to
consider the 'tmp_perc' garbage value as a valid memory address
allocated via 'g_malloc()', triggering an invalid 'free()' causing the
crash.

Rather than adding a scope '{}' within 'case', and causing a huge
noise in git diff, we just move the declaration to an upper scope.
@ximion ximion merged commit 3605809 into PackageKit:main Mar 23, 2024
3 checks passed
@ximion
Copy link
Collaborator

ximion commented Mar 23, 2024

Thank you! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants