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

fixed memory leaks for -clar -cln -ln -lar #51

Merged
merged 1 commit into from
Sep 15, 2020
Merged

fixed memory leaks for -clar -cln -ln -lar #51

merged 1 commit into from
Sep 15, 2020

Conversation

Bwoltz
Copy link
Contributor

@Bwoltz Bwoltz commented Sep 15, 2020

🚀 Description

Plugging memory leaks for Issue "Lots of memory leaks #50"

📄 Motivation and Context

Memory fixes

🧪 How Has This Been Tested?

Tested using:
valgrind --leak-check=full -v ./lst -clar
valgrind --leak-check=full -v ./lst -cln
valgrind --leak-check=full -v ./lst -lar
valgrind --leak-check=full -v ./lst -ln

📦 Types of changes

  • Bug fix (non-breaking change which fixes an issue)

note.c:

-added "wordfree(&mainDir);" to line 394 in clearNotes()
-added "wordfree(&archiveDir);" to line 426 in clearArchiveNotes()
The above lines free the words even if there's an early return in the case of no notes

helper.c:

-added "free(--temp);" to line 86 in getCurrentNotePath()
This is necessary since "cJSON_PrintUnformatted()" returns a malloced char array
-added "closedir(directory);" on line 194 in printDirectory()
That way in the case of an early return, the directory is still freed, which didn't occur before

@scamacho23 scamacho23 merged commit 9e06f2d into scamacho23:master Sep 15, 2020
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