summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 69a8383..926c492 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -870,6 +870,18 @@ TclSetByteCodeFromAny(
}
/*
+ * After optimization is all done, check that byte code length limits
+ * are not exceeded. Bug [27b3ce2997].
+ */
+ if ((compEnv.codeNext - compEnv.codeStart) > INT_MAX) {
+ /*
+ * Cannot just return TCL_ERROR as callers ignore return value.
+ * TODO - May be use TclCompileSyntaxError here?
+ */
+ Tcl_Panic("Maximum byte code length %d exceeded.", INT_MAX);
+ }
+
+ /*
* Change the object into a ByteCode object. Ownership of the literal
* objects and aux data items passes to the ByteCode object.
*/