From 90f203bff189706c2dec34482475b89d0a232597 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 19 Nov 2012 22:12:16 +0100 Subject: make goto tables local to macro invocation: they are declared on the C++ callstack since macro invocations result in nested macro_execute() calls otherwise a macro could set labels with program counters which are invalid in other macros/the command line --- qbuffers.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'qbuffers.cpp') diff --git a/qbuffers.cpp b/qbuffers.cpp index 77fefd5..26e4599 100644 --- a/qbuffers.cpp +++ b/qbuffers.cpp @@ -18,6 +18,7 @@ #include "undo.h" #include "parser.h" #include "expressions.h" +#include "goto.h" #include "qbuffers.h" namespace States { @@ -142,6 +143,9 @@ QRegister::undo_edit(void) void QRegister::execute(void) throw (State::Error) { + GotoTable *parent_goto_table = goto_table; + GotoTable macro_goto_table; + State *parent_state = States::current; gint parent_pc = macro_pc; gchar *str; @@ -156,6 +160,7 @@ QRegister::execute(void) throw (State::Error) macro_pc = 0; str = get_string(); + goto_table = ¯o_goto_table; try { macro_execute(str); @@ -163,12 +168,14 @@ QRegister::execute(void) throw (State::Error) g_free(str); macro_pc = parent_pc; States::current = parent_state; + goto_table = parent_goto_table; throw; /* forward */ } g_free(str); macro_pc = parent_pc; States::current = parent_state; + goto_table = parent_goto_table; } bool -- cgit v1.2.3