Skip to content

Commit ed8e9a9

Browse files
Fixed another memory leak.
1 parent 9e38e4c commit ed8e9a9

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

csloc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,14 @@ csloc(const char *dir, csloc_filenp *dat, size_t *sz, unsigned ops, size_t cr, c
266266
{
267267
// get last file
268268
currf = stack[--fcnt];
269-
len=strlen(currf), cnt=csloc____cnt_sub_dirs(currf);
269+
cnt=csloc____cnt_sub_dirs(currf);
270270
if(cnt <= 2)
271+
{
272+
free(currf);
271273
continue;
274+
}
272275

276+
len=strlen(currf);
273277
// get subdirectories and files
274278
names=malloc(sizeof(char*)*cnt);
275279
csloc_check_pointer(names);

get_sub_dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ int csloc____cnt_sub_dirs(const char *dir)
3838
{
3939
if(errno == EACCES)
4040
fprintf(stderr, "Could not go into %s, permission denied, maybe try running as superuser.\n", search);
41+
else
42+
perror("Opening directory failed.");
4143
goto fini;
4244
}
4345
struct dirent *de = readdir(dr);

main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#endif
1818
#include"csloc.h"
1919
#define VERSION_MINOR "9"
20-
#define VERSION_PATCH "0-rc1"
20+
#define VERSION_PATCH "0"
2121
int main(int argl,char*argv[])
2222
{
2323
if(argl==1)

0 commit comments

Comments
 (0)