PATCH: Coverity CID 439086 fix potential leak of prog in ptyread()

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
This was originally marked as a false positive because the allocation
was done with PAT_STATIC; when that was later changed to PAT_ZDUP to
avoid problems with signal handlers stomping on the memory, apparently
this cleanup path was missed.
---
 Src/Modules/zpty.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index c2656698c5..b766865dd1 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -690,6 +690,8 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
 	) {
 	cmd->old = (char *) zalloc(cmd->olen = used);
 	memcpy(cmd->old, buf, cmd->olen);
+	if (prog)
+	    freepatprog(prog);
 
 	return 1;
     }
-- 
2.38.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.