diff options
| author | verdant <im@verdant.ee> | 2026-07-25 17:02:10 +0800 |
|---|---|---|
| committer | verdant <im@verdant.ee> | 2026-07-25 20:25:22 +0800 |
| commit | ce35eaf6a0f993de1d4bda42679bd33063304356 (patch) | |
| tree | d3388bcb1be2a04c9e173735d853a7153b6ac7df /fm.c | |
| parent | b9aacfb1f1a77af24603b7f5e17c0c4e3515c7cb (diff) | |
| download | sf-ce35eaf6a0f993de1d4bda42679bd33063304356.tar.gz sf-ce35eaf6a0f993de1d4bda42679bd33063304356.zip | |
Free the memory of buf to avoid leaking
Diffstat (limited to 'fm.c')
| -rw-r--r-- | fm.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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) { |
