From 6e44927248852ae0356d9d3e1cfa3d69597a66b1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Sep 2020 13:43:49 +0000 Subject: Folow-up to previous commit: ExecStack is a FLEXARRAY too --- generic/tclExecute.c | 6 +++--- generic/tclInt.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tclExecute.c b/generic/tclExecute.c index aacf565..4d92468 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -914,8 +914,8 @@ TclCreateExecEnv( * [sizeof(Tcl_Obj*)] */ { ExecEnv *eePtr = ckalloc(sizeof(ExecEnv)); - ExecStack *esPtr = ckalloc(sizeof(ExecStack) - + (size_t) (size-1) * sizeof(Tcl_Obj *)); + ExecStack *esPtr = ckalloc(TclOffset(ExecStack, stackWords) + + size * sizeof(Tcl_Obj *)); eePtr->execStackPtr = esPtr; TclNewBooleanObj(eePtr->constants[0], 0); @@ -1180,7 +1180,7 @@ GrowEvaluationStack( newElems = needed; #endif - newBytes = sizeof(ExecStack) + (newElems-1) * sizeof(Tcl_Obj *); + newBytes = TclOffset(ExecStack, stackWords) + newElems * sizeof(Tcl_Obj *); oldPtr = esPtr; esPtr = ckalloc(newBytes); diff --git a/generic/tclInt.h b/generic/tclInt.h index e145925..fe69b26 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1409,7 +1409,7 @@ typedef struct ExecStack { Tcl_Obj **markerPtr; Tcl_Obj **endPtr; Tcl_Obj **tosPtr; - Tcl_Obj *stackWords[1]; + Tcl_Obj *stackWords[TCLFLEXARRAY]; } ExecStack; /* -- cgit v0.12