From 0f829441deeade2a8d5588390f4690dc4d020190 Mon Sep 17 00:00:00 2001 From: op Date: Wed, 29 Mar 2023 19:09:04 +0000 Subject: [PATCH] plug leak of tagpos in poptag() if loadbuffer() fails --- usr.bin/mg/tags.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/mg/tags.c b/usr.bin/mg/tags.c index 6cb0cf6db6a..ed12493a731 100644 --- a/usr.bin/mg/tags.c +++ b/usr.bin/mg/tags.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tags.c,v 1.26 2023/03/29 10:42:34 op Exp $ */ +/* $OpenBSD: tags.c,v 1.27 2023/03/29 19:09:04 op Exp $ */ /* * This file is in the public domain. @@ -229,8 +229,11 @@ poptag(int f, int n) } s = SLIST_FIRST(&shead); SLIST_REMOVE_HEAD(&shead, entry); - if (loadbuffer(s->bname) == FALSE) + if (loadbuffer(s->bname) == FALSE) { + free(s->bname); + free(s); return (FALSE); + } curwp->w_dotline = s->dotline; curwp->w_doto = s->doto; -- 2.20.1