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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

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.
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.

1 participant