From 1b79972ccb35d9fe6174c5c6f045a9b2fcbe0af8 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Mon, 5 Sep 2016 09:35:18 +1000 Subject: [PATCH] Fix a crash due to cached local command resolution When a 'local' command is deleted, the proc epoch needs to increase to ensure that subsequent lookups are re-resolved. Signed-off-by: Steve Bennett --- jim.c | 2 +- regtest.tcl | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/jim.c b/jim.c index bb32f09..9dc2502 100644 --- a/jim.c +++ b/jim.c @@ -4991,8 +4991,8 @@ static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands) } else { Jim_DeleteHashEntry(ht, fqname); - Jim_InterpIncrProcEpoch(interp); } + Jim_InterpIncrProcEpoch(interp); } Jim_DecrRefCount(interp, cmdNameObj); JimFreeQualifiedName(interp, fqObjName); diff --git a/regtest.tcl b/regtest.tcl index 28bd43d..4f4b459 100644 --- a/regtest.tcl +++ b/regtest.tcl @@ -252,6 +252,21 @@ $f writable {incr y} $f close puts "TEST 34 PASSED" +# REGTEST 35 +# caching of command resolution after local proc deleted +set result {} +proc x {} { } +proc p {n} { + if {$n in {2 3}} { + local proc x {} { } + } + x +} +foreach i {1 2 3 4} { + p $i +} +puts "TEST 35 PASSED" + # TAKE THE FOLLOWING puts AS LAST LINE puts "--- ALL TESTS PASSED ---" -- 2.11.4.GIT