diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2003-05-14 23:01:55 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2003-05-14 23:01:55 (GMT) |
commit | 1ad94c0d2671be35fab7703ec267713ffae9a7be (patch) | |
tree | cb32e64731eef59ecc4e9b6f2854dc5dd4e170cf /generic/tclCmdAH.c | |
parent | 5fca09d9090a00e5078e577570942955451d7736 (diff) | |
download | tcl-1ad94c0d2671be35fab7703ec267713ffae9a7be.zip tcl-1ad94c0d2671be35fab7703ec267713ffae9a7be.tar.gz tcl-1ad94c0d2671be35fab7703ec267713ffae9a7be.tar.bz2 |
Consequent fixes from [Bug 699060]; [format] should not be too eager to demote
wides to ints, and should throw errors when appropriate.
Diffstat (limited to 'generic/tclCmdAH.c')
-rw-r--r-- | generic/tclCmdAH.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 596795a..2e6ba99 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdAH.c,v 1.27.2.5 2003/04/16 23:31:42 dgp Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.27.2.6 2003/05/14 23:01:56 dkf Exp $ */ #include "tclInt.h" @@ -2203,7 +2203,14 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv) break; } else { whichValue = INT_VALUE; - intValue = (int) Tcl_WideAsLong(wideValue); + if (wideValue>ULONG_MAX || wideValue<LONG_MIN) { + /* + * Value too big for type. Generate an error. + */ + Tcl_GetLongFromObj(interp, objv[objIndex], &intValue); + goto fmtError; + } + intValue = Tcl_WideAsLong(wideValue); } } else if (objv[objIndex]->typePtr == &tclIntType) { Tcl_GetLongFromObj(NULL, objv[objIndex], &intValue); |