Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH 10/17: whence: use dupstring to not leak memory



All other assignments to buf use the heap, and it's never freed. Found
by Coverity (Issue 1255786).
---
 Src/builtin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Src/builtin.c b/Src/builtin.c
index 2b9c4de..ae7f53b 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3322,7 +3322,7 @@ bin_whence(char *nam, char **argv, Options ops, int func)
 	    for (pp = path; *pp; pp++) {
 		if (**pp) {
 		    buf = zhtricat(*pp, "/", *argv);
-		} else buf = ztrdup(*argv);
+		} else buf = dupstring(*argv);
 
 		if (iscom(buf)) {
 		    if (wd) {
-- 
2.2.0.GIT



Messages sorted by: Reverse Date, Date, Thread, Author