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

Common file.c util leaks #1661

Merged
merged 6 commits into from
Dec 22, 2024
Merged

Conversation

MattCatz
Copy link
Contributor

Because file_read allocates memory, it should be free-ed. Currently,
attempting to do so will cause a compiler warning since free does
not take const qualified pointer (because we are modifying the
memory).

Changing the return type to char * rather than const char * will
allow the caller to correctly free memory.

Also fix most of the transitive leaks I could find. e.x. strdup returns allocated memory that should be free-ed.

Last patch doesn't really fix anything but adds the malloc function attribute for the compiler but also to hint to developers that the function allocates memory that needs to be free-ed.

MattCatz and others added 6 commits August 19, 2024 12:37
Because `file_read` allocates memory, it should be free-ed. Currently,
attempting to do so will cause a compiler warning since `free` does
not take `const` qualified pointer (because we are modifying the
memory).

Changing the return type to `char *` rather than `const char *` will
allow the caller to correctly free memory.
Copy link
Member

@Aemiii91 Aemiii91 left a comment

Choose a reason for hiding this comment

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

Very nice 👌

@Aemiii91 Aemiii91 added this pull request to the merge queue Dec 22, 2024
Merged via the queue into OnionUI:main with commit fb7eb75 Dec 22, 2024
2 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.

2 participants