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 <droundy@abridgegame.org>
What-a-great-system: Valgrind
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;