forked from daphne-eu/daphne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DAPHNE-daphne-eu#770] Refactor getLine() to avoid potential memory leak
According to [1], the use of the C function getLine() will automatically malloc() the required memory if NULL is passed as the first parameter. Since we constantly pass NULL in a loop without ever free()-ing the returned line this constitutes a memory leak. This commit changes the behaviour to always pass the same pointer that is now contained in the File struct. With this the malloc() happens once, the memory is subsequently realloc()-ed if needed and the pointer is passed to free() when closing the file. [1] https://linux.die.net/man/3/getline
- Loading branch information
1 parent
47e2621
commit c3266c0
Showing
4 changed files
with
77 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters