less/backport-Fix-minor-memory-leak-with-input-preprocessor.-150.patch

32 lines
743 B
Diff

From da495f5340e5756c0e1dab1e53c2235c3e54660d Mon Sep 17 00:00:00 2001
From: keinflue <80230456+keinflue@users.noreply.github.com>
Date: Fri, 16 Apr 2021 21:12:11 +0000
Subject: [PATCH] Fix minor memory leak with input preprocessor. (#150)
If the read doesn't succeed, readfd still returns a malloc'ed buffer.
---
filename.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/filename.c b/filename.c
index 9cfa4de..3132baa 100644
--- a/filename.c
+++ b/filename.c
@@ -946,10 +946,13 @@ open_altfile(filename, pf, pfd)
cmd = readfd(fd);
pclose(fd);
if (*cmd == '\0')
+ {
/*
* Pipe is empty. This means there is no alt file.
*/
+ free(cmd);
return (NULL);
+ }
return (cmd);
#endif /* HAVE_POPEN */
}
--
1.8.3.1