From ce35eaf6a0f993de1d4bda42679bd33063304356 Mon Sep 17 00:00:00 2001 From: verdant Date: Sat, 25 Jul 2026 17:02:10 +0800 Subject: Free the memory of buf to avoid leaking --- fm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fm.c b/fm.c index 3339d9b..ab096ea 100644 --- a/fm.c +++ b/fm.c @@ -186,8 +186,10 @@ static char *fm_print_preview_content(window *w, const char *path) { char *buf = xmalloc(sizeof(char) * PATH_MAX); FILE *fp = fopen(path, "r"); - if (!fp) + if (!fp) { + free(buf); die("Cannot open file: %s", path); + } int i = 0; while (fgets(buf, PATH_MAX, fp) != NULL && i < w->height) { -- cgit v1.2.3