diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2001-04-07 03:15:38 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2001-04-07 03:15:38 (GMT) |
commit | efadd9fc6a4ab636317014c0d288a78c4151664f (patch) | |
tree | 873bc5f90dbb128c2fdeff5fee278e6b6a11e1ee | |
parent | fc43ab2356c5126058af8392723740b01af546c5 (diff) | |
download | tcl-efadd9fc6a4ab636317014c0d288a78c4151664f.zip tcl-efadd9fc6a4ab636317014c0d288a78c4151664f.tar.gz tcl-efadd9fc6a4ab636317014c0d288a78c4151664f.tar.bz2 |
Avoid panic when there are extra items in the tcl stack
[Bug #406709, Patch #414470]
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclExecute.c | 10 | ||||
-rw-r--r-- | tests/foreach.test | 11 |
3 files changed, 23 insertions, 4 deletions
@@ -1,5 +1,11 @@ 2001-04-07 Miguel Sofer <msofer@users.sourceforge.net> + * generic/tclExecute.c: Avoid panic when there are extra items in + the tcl stack [Bug #406709, Patch #414470] + * tests/foreach.test: test to exercise the patch + +2001-04-07 Miguel Sofer <msofer@users.sourceforge.net> + * doc/namespace.n: document correct functionality * generic/tclNamesp.c: corrected behaviour of [namespace code] (Bug #219385, Patch #403530) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 2bd71f9..fcad4a5 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclExecute.c,v 1.20 2001/03/13 09:31:37 dkf Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.21 2001/04/07 03:15:38 msofer Exp $ */ #include "tclInt.h" @@ -635,11 +635,15 @@ TclExecuteByteCode(interp, codePtr) Tcl_SetObjResult(interp, valuePtr); TclDecrRefCount(valuePtr); if (stackTop != initStackTop) { - fprintf(stderr, "\nTclExecuteByteCode: done instruction at pc %u: stack top %d != entry stack top %d\n", + /* + * if extra items in the stack, clean up the stack before return + */ + if (stackTop > initStackTop) goto abnormalReturn; + fprintf(stderr, "\nTclExecuteByteCode: done instruction at pc %u: stack top %d < entry stack top %d\n", (unsigned int)(pc - codePtr->codeStart), (unsigned int) stackTop, (unsigned int) initStackTop); - panic("TclExecuteByteCode execution failure: end stack top != start stack top"); + panic("TclExecuteByteCode execution failure: end stack top < start stack top"); } TRACE_WITH_OBJ(("=> return code=%d, result=", result), iPtr->objResultPtr); diff --git a/tests/foreach.test b/tests/foreach.test index 4b2a9da..d753fe5 100644 --- a/tests/foreach.test +++ b/tests/foreach.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: foreach.test,v 1.6 2000/04/10 17:18:59 ericm Exp $ +# RCS: @(#) $Id: foreach.test,v 1.7 2001/04/07 03:17:24 msofer Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -210,6 +210,15 @@ test foreach-5.4 {break tests} { catch {break foo} msg set msg } {wrong # args: should be "break"} +# Check for bug #406709 +test foreach-5.5 {break tests} { + proc a {} { + set a 1 + foreach b b {list [concat a; break]; incr a} + incr a + } + a +} {2} # Test for incorrect "double evaluation" semantics |