summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-23 10:09:24 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-23 10:09:24 -0500
commit626b1fd062faa08cbdf47f2ae0a2447ce248dda9 (patch)
treedd5d956594f5483e047916acd6596af710a49b25
parent275fbdbe040dc07b2705c92d4cd24ad3f3c7d069 (diff)
downloadbfs-626b1fd062faa08cbdf47f2ae0a2447ce248dda9.tar.xz
bftw: Plug a leak when the root is not a directory.
-rw-r--r--bftw.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bftw.c b/bftw.c
index bab357d..d216481 100644
--- a/bftw.c
+++ b/bftw.c
@@ -511,7 +511,6 @@ static int dirqueue_push(struct dirqueue *queue, struct dircache_entry *entry) {
/** Remove an entry from the dirqueue. */
static struct dircache_entry *dirqueue_pop(struct dirqueue *queue) {
if (queue->front == queue->back) {
- free(queue->entries);
return NULL;
}
@@ -522,6 +521,11 @@ static struct dircache_entry *dirqueue_pop(struct dirqueue *queue) {
return entry;
}
+/** Destroy a dirqueue. */
+static void dirqueue_free(struct dirqueue *queue) {
+ free(queue->entries);
+}
+
/** Fill in ftwbuf fields with information from a struct dirent. */
static void ftwbuf_use_dirent(struct BFTW *ftwbuf, const struct dirent *de) {
#if defined(_DIRENT_HAVE_D_TYPE) || defined(DT_DIR)
@@ -909,6 +913,7 @@ static void bftw_state_free(struct bftw_state *state) {
while (state->current) {
bftw_pop(state, false);
}
+ dirqueue_free(&state->queue);
dircache_free(&state->cache);