From 04dc4095f6bf5b1b8ea785d1ec84f674c03b97c3 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 12 Apr 2015 21:42:18 +0000 Subject: [PATCH] Prevent use after free in definemacro(). When the startup file contains (start-kbd-macro) mg crashes when executing "start-kbd-macro" two times in the running mg. The problem is that execline() is cleaning up behind our backs. Finish the cleanup and make sure mg doesn't think we are in the middle of a macro definition. Problem found, tracked down and diff by gsoares@ Tweaked & OK by me. Committing on request of gsoares@ who currently doesn't have good net to commit. --- usr.bin/mg/extend.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c index 26d623809fb..083ea30eda9 100644 --- a/usr.bin/mg/extend.c +++ b/usr.bin/mg/extend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: extend.c,v 1.61 2015/03/24 22:28:10 bcallah Exp $ */ +/* $OpenBSD: extend.c,v 1.62 2015/04/12 21:42:18 florian Exp $ */ /* This file is in the public domain. */ @@ -911,6 +911,8 @@ cleanup: lp = np; } free(lp); + maclhead = NULL; + macrodef = FALSE; return (status); } -- 2.20.1