From: simonmar Date: Wed, 5 Nov 2003 09:58:01 +0000 (+0000) Subject: [project @ 2003-11-05 09:58:01 by simonmar] X-Git-Tag: nhc98-1-18-release~453 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=67bb055da8e135865c305062390c0b5da7262402;p=haskell-directory.git [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 --- 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;