diff options
| author | sebres <sebres@users.sourceforge.net> | 2024-08-12 13:07:24 (GMT) |
|---|---|---|
| committer | sebres <sebres@users.sourceforge.net> | 2024-08-12 13:07:24 (GMT) |
| commit | 7c603bb3f40a4c0f2903eecb0ea92d9bfec5eb55 (patch) | |
| tree | 992d97ea1f0016587675084de3d8fa9c88ba1fa9 | |
| parent | 2c28b11277b488c5a421ebc815cf60e23299b38e (diff) | |
| download | tcl-7c603bb3f40a4c0f2903eecb0ea92d9bfec5eb55.zip tcl-7c603bb3f40a4c0f2903eecb0ea92d9bfec5eb55.tar.gz tcl-7c603bb3f40a4c0f2903eecb0ea92d9bfec5eb55.tar.bz2 | |
fixes [7179c6724cd38271]: compilation of incr command on wide constant offset (no overflow)
| -rw-r--r-- | generic/tclCompCmds.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 3b234b0..5f2dc43 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -2285,10 +2285,19 @@ TclCompileIncrCmd( Tcl_Obj *intObj = Tcl_NewStringObj(word, numBytes); Tcl_IncrRefCount(intObj); code = TclGetIntFromObj(NULL, intObj, &immValue); - TclDecrRefCount(intObj); - if ((code == TCL_OK) && (-127 <= immValue) && (immValue <= 127)) { + if ( (code == TCL_OK) + && (-127 <= immValue) && (immValue <= 127) +#ifndef NO_WIDE_TYPE + /* avoid overflow during string to int conversion (wide 0xFFFFFFFF to signed int -1): */ + && ( (immValue >= 0) + || (intObj->typePtr != &tclWideIntType) + || ((-127 <= intObj->internalRep.wideValue) && (intObj->internalRep.wideValue <= 127)) + ) +#endif + ) { haveImmValue = 1; } + TclDecrRefCount(intObj); if (!haveImmValue) { PushLiteral(envPtr, word, numBytes); } |
