aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorverdant <im@verdant.ee>2026-07-25 17:02:10 +0800
committerverdant <im@verdant.ee>2026-07-25 20:25:22 +0800
commitce35eaf6a0f993de1d4bda42679bd33063304356 (patch)
treed3388bcb1be2a04c9e173735d853a7153b6ac7df
parentb9aacfb1f1a77af24603b7f5e17c0c4e3515c7cb (diff)
downloadsf-ce35eaf6a0f993de1d4bda42679bd33063304356.tar.gz
sf-ce35eaf6a0f993de1d4bda42679bd33063304356.zip
Free the memory of buf to avoid leaking
-rw-r--r--fm.c4
1 files changed, 3 insertions, 1 deletions
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) {