From 878cd6e8792d5ac03eea59fec9fe8e325440d50c Mon Sep 17 00:00:00 2001 From: Vincent Douillet Date: Wed, 23 Oct 2024 09:01:24 +0200 Subject: file: fix memory leaks --- browse.c | 2 +- download.c | 4 +--- file.h | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/browse.c b/browse.c index 801b539..be72e34 100644 --- a/browse.c +++ b/browse.c @@ -370,7 +370,7 @@ browse(struct kreq * r) end: page_template_free(tmpl); if (file != NULL) { - free(file); + file_free(file); file = NULL; } while (!SLIST_EMPTY(&list)) { diff --git a/download.c b/download.c index 008de02..02625fc 100644 --- a/download.c +++ b/download.c @@ -172,8 +172,6 @@ download(struct kreq * r) end: if (f != NULL && f->size > 0) munmap(buffer, f->size); - if (f != NULL) - free(f); - + file_free(f); return ret; } diff --git a/file.h b/file.h index 1ede156..a478e98 100644 --- a/file.h +++ b/file.h @@ -63,7 +63,8 @@ struct file * file_new(const char *); /* - * Get the file basename. + * Get the file basename. Returns NULL in case of error or a malloced string in + * case of success. */ char * file_get_basename(const struct file *); -- cgit v1.2.3