diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-02-23 10:09:24 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-02-23 10:09:24 -0500 |
commit | 626b1fd062faa08cbdf47f2ae0a2447ce248dda9 (patch) | |
tree | dd5d956594f5483e047916acd6596af710a49b25 /bftw.c | |
parent | 275fbdbe040dc07b2705c92d4cd24ad3f3c7d069 (diff) | |
download | bfs-626b1fd062faa08cbdf47f2ae0a2447ce248dda9.tar.xz |
bftw: Plug a leak when the root is not a directory.
Diffstat (limited to 'bftw.c')
-rw-r--r-- | bftw.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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); |