From 80edfd53accc6b7bea4d66fca5d8ed2f4d0fb699 Mon Sep 17 00:00:00 2001 From: warrenlc <88832598+warrenlc@users.noreply.github.com> Date: Sat, 25 Mar 2023 15:04:41 +0100 Subject: [PATCH] Update simple-ls-ver2.c Valgrind shows a memory leak related to the function call d = opendir(path) on line 50. Very much appreciate the book, btw. Helping me learn and get comfortable with C! --- kapitel11/simple-ls-ver2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kapitel11/simple-ls-ver2.c b/kapitel11/simple-ls-ver2.c index 5a031ab..2422498 100644 --- a/kapitel11/simple-ls-ver2.c +++ b/kapitel11/simple-ls-ver2.c @@ -62,7 +62,9 @@ int main(int argc, char **argv) printf("%s\n", dir->d_name); } } - return 0; + + closedir(d); + return 0; } void printUsage(char *arg)