diff options
author | dgp <dgp@users.sourceforge.net> | 2009-09-28 21:20:50 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2009-09-28 21:20:50 (GMT) |
commit | 28523989f9ad311e862b34539a2aefd708fcbb5a (patch) | |
tree | 4bbcc35d2c98ef432ee08599ec2bd541b906a6ba /generic/tclParse.c | |
parent | 2aa45635bb65ab27ecc692076b072560a603d4d3 (diff) | |
download | tcl-28523989f9ad311e862b34539a2aefd708fcbb5a.zip tcl-28523989f9ad311e862b34539a2aefd708fcbb5a.tar.gz tcl-28523989f9ad311e862b34539a2aefd708fcbb5a.tar.bz2 |
* generic/tclAlloc.c: Cleaned up various routines in the
* generic/tclCkalloc.c: call stacks for memory allocation to
* generic/tclParse.c: guarantee that any size values computed
* generic/tclThreadAlloc.c: are within the domains of the routines
they get passed to. [Bugs 2557696 and 2557796].
Diffstat (limited to 'generic/tclParse.c')
-rw-r--r-- | generic/tclParse.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c index e939ef3..93d1741 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclParse.c,v 1.25.2.3 2007/10/15 13:29:19 msofer Exp $ + * RCS: @(#) $Id: tclParse.c,v 1.25.2.4 2009/09/28 21:20:51 dgp Exp $ */ #include "tclInt.h" @@ -1019,7 +1019,15 @@ TclExpandTokenArray(parsePtr) int newCount; Tcl_Token *newPtr; +#define MAX_TOKENS (int)(UINT_MAX / sizeof(Tcl_Token)) + + if (parsePtr->tokensAvailable == MAX_TOKENS) { + Tcl_Panic("max # of tokens for a Tcl parse (%d) exceeded", MAX_TOKENS); + } newCount = parsePtr->tokensAvailable*2; + if (newCount > MAX_TOKENS) { + newCount = MAX_TOKENS; + } newPtr = (Tcl_Token *) ckalloc((unsigned) (newCount * sizeof(Tcl_Token))); memcpy((VOID *) newPtr, (VOID *) parsePtr->tokenPtr, (size_t) (parsePtr->tokensAvailable * sizeof(Tcl_Token))); |