From 67bb055da8e135865c305062390c0b5da7262402 Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 5 Nov 2003 09:58:01 +0000 Subject: [PATCH] [project @ 2003-11-05 09:58:01 by simonmar] Fix a memory leak in __hscore_readdir() which meant that one struct dirent was leaked at the end of each directory read. Bug-reported-by: David Roundy What-a-great-system: Valgrind --- cbits/dirUtils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cbits/dirUtils.c b/cbits/dirUtils.c index 4422440..f256463 100644 --- a/cbits/dirUtils.c +++ b/cbits/dirUtils.c @@ -81,7 +81,11 @@ __hscore_readdir( HsAddr dirPtr, HsAddr pDirEnt ) if (p == NULL) return -1; res = readdir_r((DIR*)dirPtr, p, pDirE); if (res != 0) { - *pDirE = NULL; + *pDirE = NULL; + free(p); + } + else if (*pDirE == NULL) { + // end of stream free(p); } return res; -- 1.7.10.4