Tcl Source Code

Artifact [e4303eb852]
Login

Artifact e4303eb8524fd1914cec4a405ed0610c8dff4424:

Attachment "dict-for.patch" to ticket [1382528fff] added by a_kovalenko 2005-12-16 23:58:55.
Index: tclCompCmds.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompCmds.c,v
retrieving revision 1.82
diff -u -r1.82 tclCompCmds.c
--- tclCompCmds.c	30 Nov 2005 14:59:40 -0000	1.82
+++ tclCompCmds.c	16 Dec 2005 16:57:01 -0000
@@ -740,18 +740,20 @@
 
 	CompileWord(envPtr, dictTokenPtr, interp);
 	TclEmitInstInt4( INST_DICT_FIRST, infoIndex,		envPtr);
-	doneTargetOffset = CurrentOffset(envPtr);
-	TclEmitInstInt4( INST_JUMP_TRUE4, 0,			envPtr);
 
 	/*
 	 * Now we catch errors from here on so that we can finalize the search
-	 * started by Tcl_DictObjFirst above.
+	 * started by Tcl_DictObjFirst above. We do it even before JUMP_TRUE,
+	 * so the stack is not broken on dict for with empty dicts.
 	 */
 
 	catchRange = DeclareExceptionRange(envPtr, CATCH_EXCEPTION_RANGE);
 	TclEmitInstInt4( INST_BEGIN_CATCH4, catchRange,		envPtr);
 	ExceptionRangeStarts(envPtr, catchRange);
 
+	doneTargetOffset = CurrentOffset(envPtr);
+	TclEmitInstInt4( INST_JUMP_TRUE4, 0,			envPtr);
+
 	/*
 	 * Inside the iteration, write the loop variables.
 	 */