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

Fix some compiler warnings #5362

Merged
merged 2 commits into from Mar 20, 2023
Merged

Fix some compiler warnings #5362

merged 2 commits into from Mar 20, 2023

Conversation

smcv
Copy link
Collaborator

@smcv smcv commented Mar 20, 2023

  • dir: Consistently initialize g_autofree variables

    All g_autofree and g_autoptr variables should be initialized, either
    with a value or NULL, and some gcc versions warn if they are not.

    This particular instance was harmless, because we initialized regexp
    to either NULL or a valid non-NULL value as the first statement of the
    function, so there was no way to return before regexp was initialized;
    but if we introduced an early-return such as a g_return_val_if_fail
    before the current first statement, then that early return would have
    caused uninitialized stack contents to be freed, likely resulting in a
    crash.

  • run: Make it clearer that rest_argv_start is not used uninitialized

    rest_argv_start is initialized whenever rest_argc != 0, so the previous
    code was in fact safe; but this wasn't obvious to either a human reader
    or the compiler, and some gcc versions warn here.

@github-advanced-security
Copy link

You have successfully added a new shellcheck configuration differential-shellcheck. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab.

All g_autofree and g_autoptr variables should be initialized, either
with a value or NULL, and some gcc versions warn if they are not.

This particular instance was harmless, because we initialized regexp
to either NULL or a valid non-NULL value as the first statement of the
function, so there was no way to return before regexp was initialized;
but if we introduced an early-return such as a g_return_val_if_fail
before the current first statement, then that early return would have
caused uninitialized stack contents to be freed, likely resulting in a
crash.

Signed-off-by: Simon McVittie <[email protected]>
rest_argv_start is initialized whenever rest_argc != 0, so the previous
code was in fact safe; but this wasn't obvious to either a human reader
or the compiler, and some gcc versions warn here.

Signed-off-by: Simon McVittie <[email protected]>
@pwithnall
Copy link
Collaborator

This LGTM, for what it’s worth

@smcv
Copy link
Collaborator Author

smcv commented Mar 20, 2023

I'm a maintainer, @pwithnall is a frequent contributor, I'm going to call that good enough.

@smcv smcv merged commit 0e3e646 into flatpak:main Mar 20, 2023
9 checks passed
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

2 participants