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 several tiny memory leaks #428

Merged
merged 1 commit into from
Feb 7, 2021

Conversation

Quipyowert2
Copy link
Contributor

  • What does this PR do?
    Fixes a series of very tiny leaks.

  • Screenshots (if applicable)

  • PR acceptance criteria (reminder only, please delete once read)

    • Your commit message(s) are descriptive. See:

      https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html

    • [https://raw.githubusercontent.com/fvwmorg/fvwm3/master/doc/README]Documentation updated (where appropriate)

    • Style guide followed (try and match the surrounding code where possible)

    • All tests are passing: although this is automatic, Codacy will often
      highlight additional considerations which will need to be addressed before
      the PR can be merged.

  • Issue number(s)

If this PR addresses any issues, please ensure the appropriate commit
message(s) contains:

Fixes #XXX

at the end of your commit message, where XXX should be replaced with the
relevant issue number.

If there is more than one issue fixed then use:

Fixes #XXX, fixes #YYY, fixes #ZZZ

Copy link
Member

@ThomasAdam ThomasAdam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Quipyowert2

Thanks, all look good. Not overly wild about the whole "Bool" checking in functions.c, but there's already a precendence for it.

See comments in-line for the FScreen.c change.

Can you also collapse these changes into one or two commits?

libs/FScreen.c Outdated Show resolved Hide resolved
libs/FScreen.c Outdated Show resolved Hide resolved
libs/FScreen.c Outdated Show resolved Hide resolved
libs/FScreen.c Show resolved Hide resolved
@Quipyowert2
Copy link
Contributor Author

I added the error message you suggested and removed the must_free_name variable since it wasn't needed. I squashed the commits into one commit but the commit message is kind of long.

@ThomasAdam
Copy link
Member

Thanks, @Quipyowert2

I would use a commit message of:

Assorted mem leak fixes

In running fvwm3 though valgrind, this commit fixes a few memory leaks it has detected.

In running fvwm3 through valgrind, this commit fixes a few memory leaks
it has detected.
Comment on lines -2386 to +2391
//free(action_cpy);
free(action_cpy_start);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Thanks for fixing this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PeekToken moves action_cpy forward a few bytes so I had to introduce another variable to be able to free the original pointer. Freeing action_cpy directly caused an Invalid free error from valgrind since it was pointing into the middle of the allocated memory instead of the beginning.

You're welcome.

@ThomasAdam ThomasAdam merged commit 6c641b3 into fvwmorg:master Feb 7, 2021
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.

2 participants