PATCH: Coverity CID 1692320 fix leak of match1

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
---
 Src/Modules/zutil.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c
index 7be25d3062..28c6e8accd 100644
--- a/Src/Modules/zutil.c
+++ b/Src/Modules/zutil.c
@@ -1401,8 +1401,10 @@ rmatch(RParseResult *sm, char *subj, char *var1, char *var2, int comp)
 	    next = br->state;
 	    if (next->pattern && !next->patprog) {
 	        tokenize(next->pattern);
-		if (!(next->patprog = patcompile(next->pattern, 0, NULL)))
+		if (!(next->patprog = patcompile(next->pattern, 0, NULL))) {
+		    freematch(&match1);
 		    return 3;
+		}
 	    }
 	    if (next->pattern && pattry(next->patprog, subj) &&
 		(!next->guard || (execstring(next->guard, 1, 0,
-- 
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.